Validar Decorators
Decorators for the validar package.
Install
npm install validar-decorators
As decorators are a part of future ECMAScript standard they can only be used with transpilers such as Babel or Typescript.
This package is written in typescript.
Example
// person.ts // @isValid decorator accepts validation @ public name: string // or array of validations @ public lastName: string @ public location: Location
// application.tsconst person = personname = 'Sam'personlastName = 'Fisher'personlocation = address: street: 'Beverly Hills' appartmentNumber: 33 city: 'LA' country: 'USA' // actual validation stepconst result = // if you have async tests
Static properties
You can also validate static properties.
static totalCount: number = 3000 static males: number = 1500 static females: number = 1500 const result = // if you have async tests
Working with subclasses
Subclasses inherit validation checks from the parent class, but they can also override them.
@ name: string = 'Sam' @ lastName: string // override validation @ name: string // override validation @ lastName: string @ nick: string const pilot = pilotname = 'Pete'pilotlastName = 'Mitchell'pilotnick = 'Maveric' // actual validation stepconst result =
For more info about validar
package check out the documentation
API docs
Validar Decorators
is written in TypeScript, auto generated API docs are available.
Author
- Ivan Vlatković
License
This project is licensed under the MIT License - see the LICENSE file for details