Skip to content

Instantly share code, notes, and snippets.

@kanian
Last active February 6, 2020 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanian/c07c3e666bd8236b14d9746748ced081 to your computer and use it in GitHub Desktop.
Save kanian/c07c3e666bd8236b14d9746748ced081 to your computer and use it in GitHub Desktop.
paramSchema decorator validation example
@schema(personSchema,/*validateParams:*/ true)
class Person {
age: number
name: string
constructor(
@paramSchema(personNameSchema) name: string,
@paramSchema(personAgeSchema) age: number
) {
;(this.age = age), (this.name = name)
}
}
new Person('Jake', 0)
// -> ValidationError: "age" must be larger than or equal to 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment