From ef2b4cc8855eae312f385a7840afb3e3fa16894b Mon Sep 17 00:00:00 2001 From: ngolechinhan Date: Wed, 30 Nov 2016 18:06:35 +0700 Subject: [PATCH 1/2] Allow override the defaultValidators Ex: override message ``` const LoginForm = forms.Form.extend({ email: forms.EmailField({validators: [EmailValidator({message:'my customize email invalid msg'})] }), password: forms.CharField({widget: forms.PasswordInput}) } ) ``` --- src/Field.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Field.js b/src/Field.js index 7eefce6..9533823 100644 --- a/src/Field.js +++ b/src/Field.js @@ -73,7 +73,8 @@ var Field = Concur.extend({ messages.push(kwargs.errorMessages) this.errorMessages = object.extend.apply(object, messages) - this.validators = this.defaultValidators.concat(kwargs.validators) + // Allow override the defaultValidators + this.validators = kwargs.validators || this.this.defaultValidators } }) @@ -192,4 +193,4 @@ Field.prototype._hasChanged = function(initial, data) { return (''+initialValue != ''+dataValue) // TODO is forcing to string necessary? } -module.exports = Field \ No newline at end of file +module.exports = Field From bc5254b77249a9949c02e4521571005a62b3b722 Mon Sep 17 00:00:00 2001 From: ngolechinhan Date: Wed, 30 Nov 2016 18:13:49 +0700 Subject: [PATCH 2/2] Update Field.js