mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Added decimal checks to metadata validator
Medatadata validator didn't have check for decimal values. It was added. https://fedorahosted.org/freeipa/ticket/3052
This commit is contained in:
parent
07cae43484
commit
77ad84f47e
@ -430,21 +430,31 @@ IPA.metadata_validator = function(spec) {
|
||||
|
||||
var message;
|
||||
var metadata = context.metadata;
|
||||
var number = false;
|
||||
|
||||
if (!metadata || IPA.is_empty(value)) return that.true_result();
|
||||
|
||||
if (metadata.type == 'int') {
|
||||
if (metadata.type === 'int') {
|
||||
number = true;
|
||||
if (!value.match(/^-?\d+$/)) {
|
||||
return that.false_result(IPA.messages.widget.validation.integer);
|
||||
}
|
||||
} else if (metadata.type === 'Decimal') {
|
||||
number = true;
|
||||
if (!value.match(/^-?\d+(\.\d+)?$/)) {
|
||||
return that.false_result(IPA.messages.widget.validation.decimal);
|
||||
}
|
||||
}
|
||||
|
||||
if (metadata.minvalue !== undefined && value < metadata.minvalue) {
|
||||
if (number) {
|
||||
|
||||
if (metadata.minvalue !== undefined && Number(value) < Number(metadata.minvalue)) {
|
||||
message = IPA.messages.widget.validation.min_value;
|
||||
message = message.replace('${value}', metadata.minvalue);
|
||||
return that.false_result(message);
|
||||
}
|
||||
|
||||
if (metadata.maxvalue !== undefined && value > metadata.maxvalue) {
|
||||
if (metadata.maxvalue !== undefined && Number(value) > Number(metadata.maxvalue)) {
|
||||
message = IPA.messages.widget.validation.max_value;
|
||||
message = message.replace('${value}', metadata.maxvalue);
|
||||
return that.false_result(message);
|
||||
|
@ -523,6 +523,7 @@
|
||||
"undo_all": "undo all",
|
||||
"validation": {
|
||||
"error": "Text does not match field pattern",
|
||||
"decimal": "Must be a decimal number",
|
||||
"integer": "Must be an integer",
|
||||
"ip_address": "Not a valid IP address",
|
||||
"ip_v4_address": "Not a valid IPv4 address",
|
||||
|
@ -662,6 +662,7 @@ class i18n_messages(Command):
|
||||
"undo_all": _("undo all"),
|
||||
"validation": {
|
||||
"error": _("Text does not match field pattern"),
|
||||
"decimal": _("Must be a decimal number"),
|
||||
"integer": _("Must be an integer"),
|
||||
"ip_address": _('Not a valid IP address'),
|
||||
"ip_v4_address": _('Not a valid IPv4 address'),
|
||||
|
Loading…
Reference in New Issue
Block a user