package.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":["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,EAAE,CAACC,IAAI,CAAC;IAChBC,IAAI,EAAE,MAAM;IACZD,IAAI,EAAE,SAAAA,KAACE,KAAK,EAAEC,GAAG,E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