Skip to content

Commit

Permalink
schema experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
ak-appinventiv committed Feb 19, 2019
1 parent 968fae2 commit 20c8619
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

// export * from './lib/index';
import { body } from './lib/index';
// import { body, method } from './lib/index';
11 changes: 11 additions & 0 deletions src/lib/schema/flag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

interface FlagOptions {
data?: any;
}

export class Flag {
constructor(
readonly name: string,
readonly options: FlagOptions = null,
) {}
}
3 changes: 3 additions & 0 deletions src/lib/schema/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

export * from './flag';
export * from './schema';
3 changes: 2 additions & 1 deletion src/lib/schema.ts → src/lib/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
* @name Schema
* @description A schema which can be validated, stringify, parsed easily transferred over internet.
*/
import { Flag } from './flag';

export class EpiSchema {
readonly methods: string[] = [];
readonly locations: string[] = [];
readonly fieldNames: string[] = [];
readonly flags: string[] = [];
readonly flags: Flag[] = [];
}
3 changes: 2 additions & 1 deletion src/lib/types/any.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @description AnyType
*/

import { EpiSchema } from '../schema';
import { EpiSchema, Flag } from '../schema/index';

export abstract class AnyType<T> {
protected _schema: EpiSchema = new EpiSchema();
Expand All @@ -15,6 +15,7 @@ export abstract class AnyType<T> {
*/
allow(...values: T[]): this {
// TO DO
this._schema.flags.push(new Flag('allow', {data: values}));
return this;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/validators/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @description All validator flags.
*/

import {} from '../schema';
import {} from '../schema/schema';

function trim() {
//
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"outDir": "dist/",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"experimentalDecorators": true,
"sourceMap": true,
"declaration": true,
"target": "es5",
Expand Down

0 comments on commit 20c8619

Please sign in to comment.