package.cjs.utils.validators.slug.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neeto-commons-frontend Show documentation
Show all versions of neeto-commons-frontend Show documentation
A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.
{"version":3,"file":"slug.js","names":["_regex","require","_i18next","yup","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","slugValidator","exports","label","string","test","name","value","ctx","createError","message","what","VALID_SLUG_REGEX","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,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,GAAA,GAAAC,uBAAA,CAAAH,OAAA;AAA2B,SAAAI,yBAAAC,CAAA,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