Last active
February 6, 2020 14:50
-
-
Save kanian/c07c3e666bd8236b14d9746748ced081 to your computer and use it in GitHub Desktop.
paramSchema decorator validation example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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