Open pto4 opened 7 years ago
The problem is how you would then validate that a.b
is required?
Sorry, I didn't understand your question. The structure of my object o
is constant.There are p1
and p2
can be changed only. The a.b
exists all time and I don't need to validate it.
Yes, but we can't allow both as we would have not way of differentiating between the two scenarios
To validate this object:
var o = { a: { b: { p1: '', p2: 'xxx' } } };
I had to write the next lines of code:
validate(o, {'a.b.p1': {presence: true}, 'a.b.p2': {presence: true}});
But, in my opinion, it would be better to writevalidate(o, {'a.b': {p1: {presence: true}, p2: {presence: true}}});
Is this possible to implement?
The main reason to allow the latter approach is that this makes possible to create a plugin for validate.js allowing to validate each array item or value which is returned by function.