bguard
Version:
**bguard** is a powerful, flexible, and type-safe validation library for TypeScript. It allows developers to define validation schemas for their data structures and ensures that data conforms to the expected types and constraints.
1 lines • 1.73 kB
Source Map (JSON)
{"version":3,"sources":["../src/asserts/string/atLeastOneLowerChar.ts"],"sourcesContent":["import type { ExceptionContext, RequiredValidation } from '../../core';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst atLeastOneLowerCharErrorMessage = 'The received value does not contain at least one lowercase character';\nconst atLeastOneLowerCharErrorKey = 's:atLeastOneLowerChar';\n\n/**\n * @description Asserts that a string value contains at least one lowercase character.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value does not contain at least one lowercase character.\n * @example\n * const schema = string().custom(atLeastOneLowerChar());\n * parseOrFail(schema, 'abcDEF'); // Valid\n * parseOrFail(schema, 'ABCDEF'); // Throws an error: 'The received value does not contain at least one lowercase character'\n *\n * @translation Error Translation Key = 's:atLeastOneLowerChar'\n */\nexport const atLeastOneLowerChar = (): RequiredValidation => (received: string, ctx: ExceptionContext) => {\n const lowerCharRegExp = /[a-z]/;\n if (!lowerCharRegExp.test(received))\n ctx.addIssue('at least one lowercase character', received, atLeastOneLowerCharErrorKey);\n};\n\natLeastOneLowerChar.key = atLeastOneLowerCharErrorKey;\natLeastOneLowerChar.message = atLeastOneLowerCharErrorMessage;\nsetToDefaultLocale(atLeastOneLowerChar);\n"],"mappings":";;;;;AAGA,IAAM,kCAAkC;AACxC,IAAM,8BAA8B;AAa7B,IAAM,sBAAsB,MAA0B,CAAC,UAAkB,QAA0B;AACxG,QAAM,kBAAkB;AACxB,MAAI,CAAC,gBAAgB,KAAK,QAAQ;AAChC,QAAI,SAAS,oCAAoC,UAAU,2BAA2B;AAC1F;AAEA,oBAAoB,MAAM;AAC1B,oBAAoB,UAAU;AAC9B,mBAAmB,mBAAmB;","names":[]}