mirror of
https://github.com/appy-one/acebase-core.git
synced 2026-05-25 14:12:16 -06:00
Merge pull request #36 from appy-one/improvement/ts-style-schema-object-parser
Improvement: TS style schema object parser
This commit is contained in:
commit
fbd28fac36
1 changed files with 14 additions and 11 deletions
|
|
@ -1,18 +1,18 @@
|
|||
export interface IType {
|
||||
typeOf: string, // typeof
|
||||
typeOf: string; // typeof
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
instanceOf?: Function, // eg: instanceof 'Array'
|
||||
value?:string|number|boolean|bigint|null,
|
||||
genericTypes?: IType[],
|
||||
children?: IProperty[],
|
||||
matches?: RegExp // NEW: enforces regular expression checks on values
|
||||
instanceOf?: Function; // eg: instanceof 'Array'
|
||||
value?: string|number|boolean|bigint|null;
|
||||
genericTypes?: IType[];
|
||||
children?: IProperty[];
|
||||
matches?: RegExp; // enforces regular expression checks on values
|
||||
}
|
||||
|
||||
export interface IProperty {
|
||||
name: string,
|
||||
optional: boolean,
|
||||
wildcard: boolean,
|
||||
types: IType[]
|
||||
name: string;
|
||||
optional: boolean;
|
||||
wildcard: boolean;
|
||||
types: IType[];
|
||||
}
|
||||
|
||||
// parses a typestring, creates checker functions
|
||||
|
|
@ -112,8 +112,11 @@ function parse(definition: string) {
|
|||
const types = readTypes();
|
||||
type.children.push({ name: prop.name, optional: prop.optional, wildcard: prop.wildcard, types });
|
||||
consumeSpaces();
|
||||
if (definition[pos] === ';' || definition[pos] === ',') {
|
||||
consumeCharacter(definition[pos]);
|
||||
consumeSpaces();
|
||||
}
|
||||
if (definition[pos] === '}') { break; }
|
||||
consumeCharacter(',');
|
||||
}
|
||||
consumeCharacter('}');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue