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

backbone validate single attribute at a time #189

Open
sapkal-manish opened this issue Nov 28, 2013 · 1 comment
Open

backbone validate single attribute at a time #189

sapkal-manish opened this issue Nov 28, 2013 · 1 comment

Comments

@sapkal-manish
Copy link

I have one model with 2 attributes as follows.

Backbone.Model.extend({
validation: {
username: [
{required: true, msg: 'Enter email/username.'},
],
password: [
{required: true,msg: 'Enter password.'},
{minLength:20,msg: 'Incorrect password length.'}]
},
});

I want validate single attribute at a time atleast in save function. means If username found invalid, then it return error and don't go for password validation, and this will come under some option/settings.

Thanks.

@giiska
Copy link

giiska commented Feb 23, 2014

You can override Backbone.Model's _validate method to filter changed attributes. Inspired from: https://github.com/fantactuka/backbone-validator/blob/master/backbone-validator.js#L178

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