@bigbinary/neeto-form-frontend 1.2.52 → 1.2.53

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.
package/dist/index.cjs.js CHANGED
@@ -806,6 +806,7 @@ var QUESTIONS_INITIAL_VALUE = {
806
806
  title: ""
807
807
  };
808
808
  var RESERVED_FIELD_CODES = ["month", "date", "time"];
809
+ var SELECTABLE_KINDS = ["radio", "checkbox", "dropdown"];
809
810
 
810
811
  function _arrayWithHoles$3(arr) {
811
812
  if (Array.isArray(arr)) return arr;
@@ -12006,13 +12007,23 @@ var formValidationSchema = yup.object().shape({
12006
12007
  }
12007
12008
  }),
12008
12009
  kind: yup.string().required(),
12009
- fieldCode: yup.string().trim().notOneOf(RESERVED_FIELD_CODES, i18next__default["default"].t("neetoForm.error.invalidFieldCode")).when("kind", function (kind, schema) {
12010
- return QUESTIONS_WITHOUT_FIELD_CODE.includes(kind) ? schema.notRequired() : requiredLabelValidation(schema, i18next__default["default"].t("neetoForm.questions.common.questionFields.field.fieldCode"));
12010
+ fieldCode: yup.string().when("_destroy", {
12011
+ is: true,
12012
+ otherwise: function otherwise(schema) {
12013
+ return schema.trim().notOneOf(RESERVED_FIELD_CODES, i18next__default["default"].t("neetoForm.error.invalidFieldCode")).when("kind", function (kind, schema) {
12014
+ return QUESTIONS_WITHOUT_FIELD_CODE.includes(kind) ? schema.notRequired() : requiredLabelValidation(schema, i18next__default["default"].t("neetoForm.questions.common.questionFields.field.fieldCode"));
12015
+ });
12016
+ }
12011
12017
  }),
12012
- optionsAttributes: yup.array().when("kind", function (kind, schema) {
12013
- return ["radio", "checkbox", "dropdown"].includes(kind) ? schema.of(yup.object().shape({
12014
- label: requiredLabelValidation(yup.string(), i18next__default["default"].t("neetoForm.questions.common.questionFields.field.option"))
12015
- })) : schema.notRequired();
12018
+ optionsAttributes: yup.array().when("_destroy", {
12019
+ is: true,
12020
+ otherwise: function otherwise(schema) {
12021
+ return schema.when("kind", function (kind, schema) {
12022
+ return SELECTABLE_KINDS.includes(kind) ? schema.of(yup.object().shape({
12023
+ label: requiredLabelValidation(yup.string(), i18next__default["default"].t("neetoForm.questions.common.questionFields.field.option"))
12024
+ })) : schema.notRequired();
12025
+ });
12026
+ }
12016
12027
  }),
12017
12028
  highestRatingLabel: yup.string().nullable(),
12018
12029
  averageRatingLabel: yup.string().nullable(),