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

package.cjs.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":["_regex","require","_i18next","yup","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","slugValidator","label","string","test","name","value","ctx","createError","message","t","what","VALID_SLUG_REGEX","includes","exports"],"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,GA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