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 {
8181 }
8282}
8383
84- export const RESERVED_NAMES = [ '_id' , 'schema' , 'kind' ] ;
85-
8684export enum CommonPattern {
8785 JSON_NAME = '[a-z]+[a-zA-Z0-9_]*[a-zA-Z0-9]+' ,
8886 URL_SLUG = '[a-z]+[a-zA-Z0-9-_]*[a-zA-Z0-9]+' ,
Original file line number Diff line number Diff line change 11import { 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' ] ;
317
418export class SchemaValidator {
519 public static ID : ValidatorFn [ ] = [
620 Validators . required ,
721 CommonValidator . noSpace ,
822 Validators . pattern ( CommonPattern . SCHEMA_ID ) ,
23+ CommonValidator . reservedName ( SCHEMA_RESERVED_IDS ) ,
924 Validators . minLength ( 3 ) ,
1025 Validators . maxLength ( 50 ) ,
1126 ] ;
@@ -22,8 +37,8 @@ export class SchemaValidator {
2237 public static FIELD_NAME : ValidatorFn [ ] = [
2338 Validators . required ,
2439 CommonValidator . noSpace ,
25- CommonValidator . reservedName ( RESERVED_NAMES ) ,
2640 Validators . pattern ( CommonPattern . JSON_NAME ) ,
41+ CommonValidator . reservedName ( SCHEMA_RESERVED_FIELD_NAMES ) ,
2742 Validators . minLength ( 2 ) ,
2843 Validators . maxLength ( 30 ) ,
2944 ] ;
You can’t perform that action at this time.
0 commit comments