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.72 kB
Source Map (JSON)
{"version":3,"sources":["../src/asserts/number/minExcluded.ts"],"sourcesContent":["import { setToDefaultLocale } from '../../translationMap';\nimport type { ExceptionContext, RequiredValidation } from '../../core';\n\nconst minExcludedErrorMessage = 'The received value is less than or equal to expected';\nconst minExcludedErrorKey = 'n:minExcluded';\n\n/**\n * @description Asserts that a number value is strictly greater than a specified minimum value (i.e., the minimum value is excluded).\n * @param {number} expected The minimum allowable value, which is excluded.\n * @returns {RequiredValidation} A validation function that takes a received number and an exception context.\n * @throws {ValidationError} if the received value is less than or equal to the expected minimum value.\n * @example\n * const schema = number().custom(minExcluded(10));\n * parseOrFail(schema, 11); // Valid\n * parseOrFail(schema, 10); // Throws an error: 'The received value is less than or equal to expected'\n * parseOrFail(schema, 9); // Throws an error: 'The received value is less than or equal to expected'\n *\n * @translation Error Translation Key = 'n:minExcluded'\n */\nexport const minExcluded =\n (expected: number): RequiredValidation =>\n (received: number, ctx: ExceptionContext) => {\n if (expected >= received) ctx.addIssue(expected, received, minExcludedErrorKey);\n };\n\nminExcluded.key = minExcludedErrorKey;\nminExcluded.message = minExcludedErrorMessage;\nsetToDefaultLocale(minExcluded);\n"],"mappings":";;;;;AAGA,IAAM,0BAA0B;AAChC,IAAM,sBAAsB;AAerB,IAAM,cACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,YAAY,SAAU,KAAI,SAAS,UAAU,UAAU,mBAAmB;AAChF;AAEF,YAAY,MAAM;AAClB,YAAY,UAAU;AACtB,mBAAmB,WAAW;","names":[]}