Closed talyssonoc closed 8 years ago
Hi,
I think you are looking for let isValid = NumberModel.test('42')
There is also a validate method that can receive a custom error collector as an argument:
NumberModel.validate('42', errors => console.log(errors))
Oh, you're right! I was looking for a way to do that directly from the instance but it will work too. Thanks! :smile:
Models instances are necessarily valid, this is the whole point of strong type checking. If an operation on a model instance makes it invalid, the operation will not be applied.
I'd like to have something link an
isValid()
method instead of throwning an error right from the constructor, for example:Is is achievable with this lib?
Btw, nice lib!