File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
src/app/shared/validators Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,6 @@ export class CommonValidator {
81
81
}
82
82
}
83
83
84
- export const RESERVED_NAMES = [ '_id' , 'schema' , 'kind' ] ;
85
-
86
84
export enum CommonPattern {
87
85
JSON_NAME = '[a-z]+[a-zA-Z0-9_]*[a-zA-Z0-9]+' ,
88
86
URL_SLUG = '[a-z]+[a-zA-Z0-9-_]*[a-zA-Z0-9]+' ,
Original file line number Diff line number Diff line change 1
1
import { ValidatorFn , Validators } from '@angular/forms' ;
2
- import { CommonPattern , CommonValidator , RESERVED_NAMES } from './common.validator' ;
2
+ import { CommonPattern , CommonValidator } from './common.validator' ;
3
+
4
+ const SCHEMA_RESERVED_IDS = [
5
+ 'Translations' ,
6
+ 'Links' ,
7
+ 'ContentMetadata' ,
8
+ 'ContentReference' ,
9
+ 'ContentRichText' ,
10
+ 'ContentLink' ,
11
+ 'ContentData' ,
12
+ 'ContentAsset' ,
13
+ 'Content' ,
14
+ ] ;
15
+
16
+ const SCHEMA_RESERVED_FIELD_NAMES = [ '_id' , 'schema' ] ;
3
17
4
18
export class SchemaValidator {
5
19
public static ID : ValidatorFn [ ] = [
6
20
Validators . required ,
7
21
CommonValidator . noSpace ,
8
22
Validators . pattern ( CommonPattern . SCHEMA_ID ) ,
23
+ CommonValidator . reservedName ( SCHEMA_RESERVED_IDS ) ,
9
24
Validators . minLength ( 3 ) ,
10
25
Validators . maxLength ( 50 ) ,
11
26
] ;
@@ -22,8 +37,8 @@ export class SchemaValidator {
22
37
public static FIELD_NAME : ValidatorFn [ ] = [
23
38
Validators . required ,
24
39
CommonValidator . noSpace ,
25
- CommonValidator . reservedName ( RESERVED_NAMES ) ,
26
40
Validators . pattern ( CommonPattern . JSON_NAME ) ,
41
+ CommonValidator . reservedName ( SCHEMA_RESERVED_FIELD_NAMES ) ,
27
42
Validators . minLength ( 2 ) ,
28
43
Validators . maxLength ( 30 ) ,
29
44
] ;
You can’t perform that action at this time.
0 commit comments