Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

42 lines
1.1 KiB

/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { map } from 'rxjs/operators';
import {
Form,
ValidatorsEx,
value$
} from '@app/framework';
const FALLBACK_NAME = 'my-app';
export class CreateAppForm extends Form<FormGroup, { name: string }> {
public appName = value$(this.form.controls['name']).pipe(map(v => v || FALLBACK_NAME));
constructor(formBuilder: FormBuilder) {
super(formBuilder.group({
name: ['',
[
Validators.required,
Validators.maxLength(40),
ValidatorsEx.pattern('[a-z0-9]+(\-[a-z0-9]+)*', 'Name can contain lower case letters (a-z), numbers and dashes (not at the end).')
]
]
}));
}
}
export class UpdateAppForm extends Form<FormGroup, { label?: string, description?: string }> {
constructor(formBuilder: FormBuilder) {
super(formBuilder.group({
label: '',
description: ''
}));
}
}