@bigbinary/neeto-rules-frontend 0.6.5 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -180,7 +180,8 @@
180
180
  "inValidEmail": "Email is invalid",
181
181
  "inValidURL": "URL is invalid",
182
182
  "noBlankSpaces": "Value should not contain blank spaces",
183
- "inValidDecimal": "Value should be a decimal number",
183
+ "positiveDecimal": "Value should be a positive decimal number.",
184
+ "decimal": "Value should be a decimal number.",
184
185
  "atLeastOne": {
185
186
  "option": "At least one option is required",
186
187
  "email": "At least one email is required",
@@ -189,7 +190,8 @@
189
190
  "atLeastOneValue": "At least one value is required",
190
191
  "emailList": "Please make sure all emails are valid.",
191
192
  "positiveInteger": "Value must be a positive integer.",
192
- "positiveNumber": "Value must be a positive number.",
193
+ "positiveNumber": "Value must be a positive whole number.",
194
+ "number": "Value must be a whole number.",
193
195
  "leadingSpace": "Can not have leading white space",
194
196
  "slack": {
195
197
  "invalidChannel": "Could not connect to the channel, please select other options.",
package/dist/index.cjs.js CHANGED
@@ -415,15 +415,13 @@ var getConditionsSchema = function getConditionsSchema(element) {
415
415
  field: yup__namespace.string().required(i18next.t("neetoRules.validations.required.condition")),
416
416
  metadata: yup__namespace.mixed().when(["field", "verb"], function (field, verb, schema) {
417
417
  var _selectedCondition$no;
418
- var selectedCondition = conditionOptions.find(function (option) {
419
- return option.value === field;
420
- });
418
+ var selectedCondition = neetoCist.findBy({
419
+ value: field
420
+ }, conditionOptions);
421
421
  var type = selectedCondition === null || selectedCondition === void 0 ? void 0 : selectedCondition.type;
422
422
  if (selectedCondition !== null && selectedCondition !== void 0 && selectedCondition.additionalData) {
423
423
  var value = selectedCondition === null || selectedCondition === void 0 ? void 0 : selectedCondition.additionalData[verb];
424
- if (value) {
425
- type = value;
426
- }
424
+ if (value) type = value;
427
425
  }
428
426
  if (selectedCondition !== null && selectedCondition !== void 0 && (_selectedCondition$no = selectedCondition.noValueForVerbs) !== null && _selectedCondition$no !== void 0 && _selectedCondition$no.includes(verb)) {
429
427
  return yup__namespace.object();
@@ -454,9 +452,11 @@ var getConditionsSchema = function getConditionsSchema(element) {
454
452
  }).required(i18next.t("neetoRules.validations.required.value"))
455
453
  });
456
454
  } else if ([CONDITION_VALUE_TYPES.number].includes(type)) {
457
- return yup__namespace.object().shape({
458
- value: yup__namespace.string().test("are-all-number", i18next.t("neetoRules.validations.positiveNumber"), function (value) {
459
- return POSITIVE_NUMBER_REGEX.test(value);
455
+ var message = selectedCondition !== null && selectedCondition !== void 0 && selectedCondition.onlyPositive ? i18next.t("neetoRules.validations.positiveNumber") : i18next.t("neetoRules.validations.number");
456
+ var regex = selectedCondition !== null && selectedCondition !== void 0 && selectedCondition.onlyPositive ? POSITIVE_NUMBER_REGEX : NUMBER_REGEX;
457
+ return yup__namespace.object({
458
+ value: yup__namespace.string().test("are-all-number", message, function (value) {
459
+ return regex.test(value);
460
460
  })
461
461
  });
462
462
  } else if ([CONDITION_VALUE_TYPES.url].includes(type)) {
@@ -471,9 +471,11 @@ var getConditionsSchema = function getConditionsSchema(element) {
471
471
  }).required(i18next.t("neetoRules.validations.required.value"))
472
472
  });
473
473
  } else if ([CONDITION_VALUE_TYPES.decimal].includes(type)) {
474
- return yup__namespace.object().shape({
475
- value: yup__namespace.string().test("are-all-number", i18next.t("neetoRules.validations.inValidDecimal"), function (value) {
476
- return DECIMAL_NUMBER_REGEX.test(value);
474
+ var _message = selectedCondition !== null && selectedCondition !== void 0 && selectedCondition.onlyPositive ? i18next.t("neetoRules.validations.positiveDecimal") : i18next.t("neetoRules.validations.decimal");
475
+ var _regex = selectedCondition !== null && selectedCondition !== void 0 && selectedCondition.onlyPositive ? POSITIVE_DECIMAL_NUMBER_REGEX : DECIMAL_NUMBER_REGEX;
476
+ return yup__namespace.object({
477
+ value: yup__namespace.string().test("are-all-number", _message, function (value) {
478
+ return _regex.test(value);
477
479
  }).required(i18next.t("neetoRules.validations.required.decimal"))
478
480
  });
479
481
  } else if ([CONDITION_VALUE_TYPES.textarea].includes(type)) {
@@ -557,15 +559,19 @@ var getActionsSchema = function getActionsSchema(element, customData) {
557
559
  }).required(i18next.t("neetoRules.validations.required.value"))
558
560
  });
559
561
  } else if ((selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.number) {
562
+ var message = selectedAction !== null && selectedAction !== void 0 && selectedAction.onlyPositive ? i18next.t("neetoRules.validations.positiveNumber") : i18next.t("neetoRules.validations.number");
563
+ var regex = selectedAction !== null && selectedAction !== void 0 && selectedAction.onlyPositive ? POSITIVE_NUMBER_REGEX : NUMBER_REGEX;
560
564
  return yup__namespace.object({
561
- value: yup__namespace.string().test("are-all-number", i18next.t("neetoRules.validations.positiveNumber"), function (value) {
562
- return POSITIVE_NUMBER_REGEX.test(value);
565
+ value: yup__namespace.string().test("are-all-number", message, function (value) {
566
+ return regex.test(value);
563
567
  })
564
568
  });
565
569
  } else if ((selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.decimal) {
570
+ var _message2 = selectedAction !== null && selectedAction !== void 0 && selectedAction.onlyPositive ? i18next.t("neetoRules.validations.positiveDecimal") : i18next.t("neetoRules.validations.decimal");
571
+ var _regex2 = selectedAction !== null && selectedAction !== void 0 && selectedAction.onlyPositive ? POSITIVE_DECIMAL_NUMBER_REGEX : DECIMAL_NUMBER_REGEX;
566
572
  return yup__namespace.object({
567
- value: yup__namespace.string().test("are-all-number", i18next.t("neetoRules.validations.inValidDecimal"), function (value) {
568
- return DECIMAL_NUMBER_REGEX.test(value);
573
+ value: yup__namespace.string().test("are-all-number", _message2, function (value) {
574
+ return _regex2.test(value);
569
575
  }).required(i18next.t("neetoRules.validations.required.decimal"))
570
576
  });
571
577
  } else if ((selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.longText) {
@@ -617,8 +623,10 @@ var FIELD_TYPES = {
617
623
  };
618
624
  var MAXIMUM_OPTION_LENGTH$1 = 7;
619
625
  var VALIDATION_SCHEMA = (_VALIDATION_SCHEMA = {}, _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.text, getSchemaForStrings), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.longText, getSchemaForStrings), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.dropdown, getSchemaForStrings), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.radio, getSchemaForStrings), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.events, getEventsSchema), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.condition, getConditionsSchema), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.actions, getActionsSchema), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.multiSelect, getSchemaForArray), _VALIDATION_SCHEMA);
620
- var DECIMAL_NUMBER_REGEX = /^\d*\.?\d+$/;
621
- var POSITIVE_NUMBER_REGEX = /^[0-9]+$/;
626
+ var DECIMAL_NUMBER_REGEX = /^-?\d*\.?\d+$/;
627
+ var NUMBER_REGEX = /^-?\d+$/;
628
+ var POSITIVE_DECIMAL_NUMBER_REGEX = /^\d*\.?\d+$/;
629
+ var POSITIVE_NUMBER_REGEX = /^\d+$/;
622
630
 
623
631
  function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
624
632
  function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }