Skip to content
This repository has been 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
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

@roipoussiere
Copy link

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