Skip to content

Instantly share code, notes, and snippets.

@kanian
Created February 6, 2020 15:27
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/0239d923683985bf316ae5eadbba7e7e to your computer and use it in GitHub Desktop.
Save kanian/0239d923683985bf316ae5eadbba7e7e to your computer and use it in GitHub Desktop.
Property Schema Decorator Validation Example
class Person {
@propertySchema(schemas.personAgeSchema)
age: number
@propertySchema(schemas.personNameSchema)
name: string
constructor(name: string, age: number) {
this.age = age
this.name = name
}
}
const p = new Person('Jake',50)
p.age = 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