What do we want?
Something similar to (roughly, not even syntactically ok):
------
class User {
@Min(10)
@Max(10)
@NotNull
private _name: string
}
------ or
class User {
private _name: string
@Min(10)
@Max(10)
@NotNull
set name (): string {
}
}
validator = new JoiValidator(...) // <- this is what we want.
user:User = new User(...)
errors:Error = validator.validate(user)
for (let error:Error of errors) {
console.log(error)
}
From JOI:
What we want is:
And this is how we can implement it: