All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.utils.validators.slug.js.map Maven / Gradle / Ivy

Go to download

A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.

There is a newer version: 4.12.3
Show newest version
{"version":3,"file":"slug.js","names":["VALID_SLUG_REGEX","t","yup","slugValidator","label","string","test","name","value","ctx","createError","message","what","includes"],"sources":["../../../src/utils/validators/slug.js"],"sourcesContent":["import { VALID_SLUG_REGEX } from \"constants/regex\";\n\nimport { t } from \"i18next\";\nimport * as yup from \"yup\";\n\nexport const slugValidator = label =>\n  yup.string().test({\n    name: \"slug\",\n    test: (value, ctx) => {\n      if (!value) {\n        return ctx.createError({\n          message: t(\"neetoCommons.validators.isRequired\", { what: label }),\n        });\n      }\n\n      if (VALID_SLUG_REGEX.test(value)) return true;\n\n      if (/[A-Z]/.test(value)) {\n        return ctx.createError({\n          message: t(\"neetoCommons.validators.mustNotContainCapitalLetters\", {\n            what: label,\n          }),\n        });\n      }\n\n      if (value?.includes(\" \")) {\n        return ctx.createError({\n          message: t(\"neetoCommons.validators.mustNotContainSpaces\", {\n            what: label,\n          }),\n        });\n      }\n\n      if (!/^[a-z0-9-]+$/.test(value)) {\n        return ctx.createError({\n          message: t(\n            \"neetoCommons.validators.mustNotContainSpecialCharactersExceptHyphen\",\n            { what: label }\n          ),\n        });\n      }\n\n      if (/^[-]|[-]$/.test(value)) {\n        return ctx.createError({\n          message: t(\n            \"neetoCommons.validators.mustNotStartOrEndWithSpecialCharacters\",\n            { what: label }\n          ),\n        });\n      }\n\n      return true;\n    },\n  });\n"],"mappings":"AAAA,SAASA,gBAAgB;AAEzB,SAASC,CAAC,QAAQ,SAAS;AAC3B,OAAO,KAAKC,GAAG,MAAM,KAAK;AAE1B,OAAO,IAAMC,aAAa,GAAG,SAAhBA,aAAaA,CAAGC,KAAK;EAAA,OAChCF,GAAG,CAACG,MAAM,CAAC,CAAC,CAACC,IAAI,CAAC;IAChBC,IAAI,EAAE,MAAM;IACZD,IAA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