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

Added notEqualTo validator #231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/backbone-validation-amd-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dist/backbone-validation-amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@
rangeLength: '{0} must be between {1} and {2} characters',
oneOf: '{0} must be one of: {1}',
equalTo: '{0} must be the same as {1}',
notEqualTo: '{0} must not be the same as {1}',
digits: '{0} must only contain digits',
number: '{0} must be a number',
email: '{0} must be a valid email',
Expand Down Expand Up @@ -620,6 +621,15 @@
}
},

// notEqual to validator
// Validates that the value has to be not equal to the value of the attribute
// with the name specified
notEqualTo: function(value, attr, notEqualTo, model, computed) {
if(value === computed[notEqualTo]) {
return this.format(defaultMessages.notEqualTo, this.formatLabel(attr, model), this.formatLabel(notEqualTo, model));
}
},

// Pattern validator
// Validates that the value has to match the pattern specified.
// Can be a regular expression or the name of one of the built in patterns
Expand Down
Loading