scotthovestadt / schema-object

Enforce schema on JavaScript objects, including type, transformation, and validation. Supports extends, sub-schemas, and arrays.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Required property does not work for falsy values

jawallace opened this issue · comments

var SO = new SchemaObject({
    val: { 
        type: Number, 
        required: true 
    }
});

var o = new SO({ val: 0 });

o.isErrors(); // true

I have a change prepared that checks explicitly for undefined rather than forcing the value to a boolean, I will submit it in a PR.

@jawallace Thanks for the PR. It's merged and I'll publish it to NPM as a non-breaking change (minor version increment) later today. The required property is a recent addition (originating from a PR) so I don't think fixing it here will break anyone's use-case.

Sounds great, thanks!

@scotthovestadt Were you able to publish this to npm yet?

@jawallace Published as 4.0.9