validator.js
validator.js copied to clipboard
Required assert should only check if value is defined
I think that the assert is doing more than it should. This shouldn't be invalid:
validator.validate({
foobar: [],
foobiz: ''
}, {
foobar: [
new Assert().Required(),
new Assert().InstanceOf(Array)
],
foobiz: [
new Assert().Required()
]
});
@guillaumepotier WDYT? Currently I'm overriding the assert but if you agree I can create a PR.
Those look quite valid, if you need to specify a length, maybe you should check Length() too, which works for strings and arrays.