Floodgate validator
Floodgate validator is a Typescript validaton library based on decorators.
Features
- Does not change class/object behaviour
- Extensible (docs on how to add validators coming soon)
- Plays nice with Typescript
Installations
npm install floodgate --save
Run tests
- Clone this repo
- Go to root of project
- runnpm install -g mocha && mocha
Usage
; // Behaves like a normal class ; // Modify.... // Validate SchemaStore.validateperson,;
Schema modes
SchemaMode.STRICT
only allows specified properties on an object. Not more not less.SchemaMode.LOOSE
only checks specified properties. Leaves other properties as they are.SchemaMode.SHORTEN
only checks specified properties. Removes all unknown properties silently.
Validators
@Nr(options)
ensures a value is a number@Bool(options)
ensures a value is a boolean@Str(options)
ensures a value is a string@Email(options)
ensures a value is an email address@Arr({ child: Type ... })
ensures a value is an array of given type@Child({ type: Type ... })
ensures a value is an object based on another schema- More to come soon