summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/src/nfvo-utils
diff options
context:
space:
mode:
authorilanap <ilanap@amdocs.com>2017-09-13 14:41:21 +0300
committerilanap <ilanap@amdocs.com>2017-09-13 15:00:13 +0300
commit2c9358a92c68a28c3ea307c9036f4721c7f0ca7e (patch)
tree81228b6cfd208a6d201bc25c6bfc9a0f2c2a42e1 /openecomp-ui/src/nfvo-utils
parent45e38d57442499a535f2915aab95a057e106d79f (diff)
Other option for license agreement term
Issue-Id: SDC-290 Change-Id: Ifeae84fd96175b656814e8b70bc67789f57ef78e Signed-off-by: ilanap <ilanap@amdocs.com>
Diffstat (limited to 'openecomp-ui/src/nfvo-utils')
-rw-r--r--openecomp-ui/src/nfvo-utils/Validator.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/openecomp-ui/src/nfvo-utils/Validator.js b/openecomp-ui/src/nfvo-utils/Validator.js
index 1df82a2ada..3f6a00e289 100644
--- a/openecomp-ui/src/nfvo-utils/Validator.js
+++ b/openecomp-ui/src/nfvo-utils/Validator.js
@@ -46,7 +46,25 @@ class Validator {
email: value => ValidatorJS.isEmail(value),
ip: value => ValidatorJS.isIP(value),
url: value => ValidatorJS.isURL(value),
- alphanumericWithUnderscores: value => ValidatorJS.isAlphanumeric(value.replace(/_/g, ''))
+ alphanumericWithUnderscores: value => ValidatorJS.isAlphanumeric(value.replace(/_/g, '')),
+ requiredChoiceWithOther: (value, otherValue) => {
+ let chosen = value.choice;
+ // if we have an empty multiple select we have a problem since it's required
+ let validationFunc = this.globalValidationFunctions['required'];
+ if (value.choices) {
+ if (value.choices.length === 0) {
+ return false;
+ } else {
+ // continuing validation with the first chosen value in case we have the 'Other' field
+ chosen = value.choices[0];
+ }
+ }
+ if (chosen !== otherValue) {
+ return validationFunc(chosen, true);
+ } else { // when 'Other' was chosen, validate other value
+ return validationFunc(value.other, true);
+ }
+ }
};
}
@@ -54,6 +72,7 @@ class Validator {
return {
required: () => i18n('Field is required'),
requiredChooseOption: () => i18n('Field should have one of these options'),
+ requiredChoiceWithOther: () => i18n('Field is required'),
maxLength: (value, maxLength) => i18n('Field value has exceeded it\'s limit, {maxLength}. current length: {length}', {
length: value.length,
maxLength