Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute "greater than" #348

Open
fatimaTalavera opened this issue Oct 20, 2017 · 1 comment
Open

Attribute "greater than" #348

fatimaTalavera opened this issue Oct 20, 2017 · 1 comment

Comments

@fatimaTalavera
Copy link

Is an extension of the min attribute possible, which only allows greater?

@Amsvartner
Copy link

Amsvartner commented Apr 25, 2018

Yes, you can use something like this.

_.extend(Backbone.Validation.validators, {
          greaterThan : function (value, attr, minValue, model) {
                var val = parseInt(value, 10);
                if (_.isNaN(val) || val <= minValue) {
                    return this.format("{0} must be greater than {1}",
                        this.formatLabel(attr, model), minValue);
                }
            }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants