Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

Apply validator even if matching data attribute is empty or 0#118

Open
i7an wants to merge 1 commit into1000hz:masterfrom
i7an:empty-data-attribute
Open

Apply validator even if matching data attribute is empty or 0#118
i7an wants to merge 1 commit into1000hz:masterfrom
i7an:empty-data-attribute

Conversation

@i7an
Copy link

@i7an i7an commented Apr 25, 2015

Html:

<input type="text" data-pizza="0" />

Js:

$form.validator({
    custom: {
        pizza: function($el) {
            return true;
        }
    },
    errors: {
        pizza: '[Pizza] Error'
    }
});

This validator wont be applied because js treats 0 as falsy.

@lypwig
Copy link

lypwig commented Aug 26, 2015

Yes! I just need it!
I think this feature is interesting, because some validations doesn't need any argument. In this case, the html line will be refined, ie <input type="text" data-foo />, instead of <input type="text" data-foo="fake-value-to-make-it-work" />.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants