-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df8496b
commit 35de0c6
Showing
25 changed files
with
454 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
|
||
|
||
export * from './lib/index'; | ||
export * from './lib/index'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
|
||
|
||
export class MyLibrary {} | ||
export class MyLibrary {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
|
||
export function parse() {} | ||
export function parse() { | ||
// | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// import { BodySchema } from './locations/body.schema'; | ||
import { NumberSchema } from './types/number.schema'; | ||
import { StringSchema } from './types/string.schema'; | ||
|
||
// new StringSchema().allow(); | ||
// new NumberSchema().min(10).allow(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { AnySchema } from '../types/any.schema'; | ||
import { StringSchema } from '../types/string.schema'; | ||
import { NumberSchema } from '../types/number.schema'; | ||
|
||
export class BodySchema extends AnySchema { | ||
string(): StringSchema { | ||
return new StringSchema(); | ||
} | ||
number(): NumberSchema { | ||
return new NumberSchema(); | ||
} | ||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
export * from './body.schema'; |
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { BaseSchema } from './base.schema'; | ||
|
||
export class AnySchema extends BaseSchema<any> {} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
export abstract class BaseSchema<T> { | ||
protected abstract location: string; | ||
protected abstract fieldName: string; | ||
protected abstract metaData: any; | ||
/** | ||
* @type Filter | ||
* @description This allow the given argument values to be truthy for filter. | ||
* @param values Argument values which are allowed to be truthy for filter. | ||
*/ | ||
allow(...values: T[]): this { | ||
// TO DO | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
* @description This disallow the given argument values to be truthy for filter. | ||
* @param values Argument values which are disallowed to be truthy for filter. | ||
*/ | ||
disallow(...values: T[]): this { | ||
// TO DO | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
* @description This function will set the required flag to true. | ||
*/ | ||
required(): this { | ||
// TO DO | ||
return this; | ||
} | ||
/** | ||
* @type MetaData | ||
* @description This function will set the label metadata to given value. | ||
*/ | ||
label(name: string): this { | ||
// TO DO | ||
return this; | ||
} | ||
/** | ||
* @type MetaData | ||
* @description This function will set the unit metadata to given value. | ||
*/ | ||
unit(): this { | ||
// TO DO | ||
return this; | ||
} | ||
/** | ||
* @type Modifier | ||
* @description This function will set the default value of the field. | ||
*/ | ||
default(value: T): this { | ||
// TO DO | ||
return this; | ||
} | ||
/** | ||
* @type MetaData | ||
* @description This function will set the example metadata to given value. | ||
*/ | ||
example(value: T): this { | ||
// TO DO | ||
return this; | ||
} | ||
description(): this { | ||
// TO DO | ||
return this; | ||
} | ||
custom(cb: (value: T) => void): this { | ||
// TO DO | ||
return this; | ||
} | ||
equalTo(value: T): this { | ||
// TO DO | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
export * from './base.schema'; | ||
export * from './any.schema'; | ||
export * from './string.schema'; | ||
export * from './number.schema'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* @name NumberSchema | ||
* @type Number | ||
* @description NumberSchema | ||
*/ | ||
|
||
import { BaseSchema } from './base.schema'; | ||
|
||
export class NumberSchema extends BaseSchema<number> { | ||
protected location: string; | ||
protected metaData: any; | ||
protected schema: string[]; | ||
constructor(protected fieldName: string) { | ||
super(); | ||
} | ||
integer(convert: boolean = false): NumberSchema { | ||
// TO DO | ||
return this; | ||
} | ||
float(convert: boolean = false): NumberSchema { | ||
// TO DO | ||
return this; | ||
} | ||
unsafe(): NumberSchema { | ||
// TO DO | ||
return this; | ||
} | ||
negative(): NumberSchema { | ||
// TO DO | ||
return this; | ||
} | ||
position(): NumberSchema { | ||
// TO DO | ||
return this; | ||
} | ||
precision(): NumberSchema { | ||
// TO DO | ||
return this; | ||
} | ||
min(num: number): NumberSchema { | ||
// TO DO | ||
return this; | ||
} | ||
max(num: number): NumberSchema { | ||
// TO DO | ||
return this; | ||
} | ||
port(): NumberSchema { | ||
// TO DO | ||
return this; | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import { BaseSchema } from './base.schema'; | ||
|
||
export class StringSchema extends BaseSchema<string> { | ||
protected location: string; | ||
protected metaData: any; | ||
protected schema: string[]; | ||
constructor(protected fieldName: string) { | ||
super(); | ||
} | ||
/** | ||
* @type Filter | ||
*/ | ||
alphanum(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
*/ | ||
regex(): StringSchema { | ||
// check for regex | ||
return this; | ||
} | ||
/** | ||
* @type Modifier, Filter | ||
* @description Lowercase value or filter lowercase value | ||
*/ | ||
lowercase(convert: boolean = true): StringSchema { | ||
// TO DO | ||
return this; | ||
} | ||
/** | ||
* @type Modifier, Filter | ||
* @description Upercase value or filter upercase value | ||
*/ | ||
uppercase(convert: boolean = true): StringSchema { | ||
// TO DO | ||
return this; | ||
} | ||
/** | ||
* @type Modifier, Filter | ||
* @description Trim value or filter trimmed value | ||
*/ | ||
trim(convert: boolean = true): StringSchema { | ||
// trim value or check if value trim | ||
return this; | ||
} | ||
/** | ||
* @type Modifier, Filter | ||
*/ | ||
trimEnd(convert: boolean = true): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Modifier, Filter | ||
*/ | ||
trimStart(convert: boolean = true): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
*/ | ||
replace(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
*/ | ||
truncate(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
*/ | ||
email(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
*/ | ||
isoDate(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
*/ | ||
jwt(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
*/ | ||
uri(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
*/ | ||
dataUri(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
*/ | ||
ip(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
*/ | ||
creditCard(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Filter | ||
*/ | ||
hostname(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Modifier | ||
*/ | ||
normalize(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
/** | ||
* @type Modifier | ||
*/ | ||
split(): StringSchema { | ||
// check for alphanum value | ||
return this; | ||
} | ||
} |
Oops, something went wrong.