js-data / js-data-schema

Define and validate rules, datatypes and schemata in Node and in the browser.
http://www.js-data.io/docs/js-data-schema
MIT License
18 stars 10 forks source link

Question about nullable #16

Open leandroz opened 9 years ago

leandroz commented 9 years ago

I have:

    var WoofSchema = schemator.defineSchema('woof', {
            text: {
                type: 'string',
                nullable: true,
                minLength: 10,
                maxLength: 300
            }
        });

I expect that if the text is null to pass the test, and if is type string to check minLength and maxLength and show errors. But setting nullable to true overwrites the other constraints.

For example:

{
    text: "hello"
}

gives no erros.

veikovx commented 8 years ago

+1 to getting this to work. Also expected it to validate when the attribute is not null.