'required' fails to validate only if the validated property is not present in the object, not when it's empty. Please see the following jsfiddle for an example (inspect in console): http://jsfiddle.net/CAc94/1/
EDIT: Sorry, jsfiddle might now validate properly, since I think I fixed it in my forked version.
That is intentional. If you want to check against strings being empty, you should use minLength: 1.
pksunkara, did you delete my comment about the design decision? Why?
what? No. I dont do that stuff.
Actually, I did not receive your comment at all in my notifications. You sure you submitted?
Hey. I was sure until I read your comment. Must've gotten lost in the interwebs.
I wanted to comment that from design perspective, it'd be helpful to have 'required' validate the presence of a value, not the property. Additionally, I'd have a flag that would then force it to validate the presence of a property. Just my $.02
@indexzero Can you decide on this?
This attribute indicates if the instance must have a value, and not
be undefined. This is false by default, making the instance
The empty string is not undefined. So this would break JSONSchema compatibility which is a primary goal.
revert #53 to fix empty string usecase
#53 changed behaviour of `required` so that an empty string wasn't acceptable which was in contra to advice in #32.
Resolve #53 by adding allowEmpty property which checks for empty strings.