diff options
author | Petr VobornÃk <pvoborni@redhat.com> | 2012-02-22 16:23:13 +0100 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2012-02-29 12:59:13 +0100 |
commit | 525bf04da56829ac2b7b6e086a7a2d965727ce02 (patch) | |
tree | 9998c2d05944bd472a775614bb272c7726835c87 /install/ui/dns.js | |
parent | 52208e8b40f98e7a7cc0c91b15803003740efa92 (diff) | |
download | freeipa.git-525bf04da56829ac2b7b6e086a7a2d965727ce02.tar.gz freeipa.git-525bf04da56829ac2b7b6e086a7a2d965727ce02.tar.xz freeipa.git-525bf04da56829ac2b7b6e086a7a2d965727ce02.zip |
Making validators to return true result if empty
All custom validators were changed to return true result if value is empty. Raising error if value is empty is resposibility of check_required call.
This fixes immediate displaying of error message in multivalued fields containing custom validators.
https://fedorahosted.org/freeipa/ticket/2351
Diffstat (limited to 'install/ui/dns.js')
-rw-r--r-- | install/ui/dns.js | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/install/ui/dns.js b/install/ui/dns.js index 8125f9d3..ddd9da03 100644 --- a/install/ui/dns.js +++ b/install/ui/dns.js @@ -2151,16 +2151,15 @@ IPA.ip_address_validator = function(spec) { that.validate = function(value) { + if (IPA.is_empty(value)) return that.true_result(); + var address = NET.ip_address(value); if (!address.valid || !that.is_type_match(address.type)) { - return { - valid: false, - message: that.message - }; + return that.false_result(); } - return { valid: true }; + return that.true_result(); }; that.is_type_match = function(net_type) { @@ -2203,21 +2202,10 @@ IPA.network_validator = function(spec) { that.specials = spec.specials || []; that.message = spec.message || IPA.messages.widget.validation.net_address; - that.false_result = function() { - return { - valid: false, - message: that.message - }; - }; - - that.true_result = function() { - return { - valid: true - }; - }; - that.validate = function(value) { + if (IPA.is_empty(value)) return that.true_result(); + if (typeof value !== 'string') return that.false_result(); if (that.specials.indexOf(value) > -1) { |