class-validators
class-validators
is runtime parameter validation for JS functions! Think PropTypes but function specific.
Installation
npm install --save class-validators
Usage
name = '' age = 0 family = @ { thisname = name } @ { thisage = age } @ { thisfamily } @ { thisfamily } const person = person // No errorperson // Throws Person#setName() expects parameter 1 to be string. Got: number
API
export const t = {
varargs(type),
optional(type),
any(),
instanceOf(class),
}
export validateMethod(...types)
License
This project is licensed under the terms of MIT License. See LICENSE
file for more info.