UNPKG

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.52 kB
{"version":3,"sources":["../src/asserts/bigint/bigintMin.ts"],"sourcesContent":["import { setToDefaultLocale } from '../../translationMap';\nimport type { ExceptionContext, RequiredValidation } from '../../core';\n\nconst bigintMinErrorMessage = 'The received value is less than expected';\nconst bigintMinErrorKey = 'bi:min';\n\n/**\n * @description Asserts that a bigint value is not less than a specified minimum value.\n * @param {bigint} expected The minimum allowable value.\n * @returns {RequiredValidation} A validation function that takes a received bigint and an exception context.\n * @throws {ValidationError} if the received value is less than the expected minimum value.\n * @example\n * const schema = bigint().custom(bigintMin(10n));\n * parseOrFail(schema, 11n); // Valid\n * parseOrFail(schema, 10n); // Valid\n * parseOrFail(schema, 9n); // Throws an error: 'The received value is less than expected'\n *\n * @translation Error Translation Key = 'bi:min'\n */\nexport const bigintMin =\n (expected: bigint): RequiredValidation =>\n (received: bigint, ctx: ExceptionContext) => {\n if (expected > received) ctx.addIssue(expected, received, bigintMinErrorKey);\n };\n\nbigintMin.key = bigintMinErrorKey;\nbigintMin.message = bigintMinErrorMessage;\nsetToDefaultLocale(bigintMin);\n"],"mappings":";;;;;AAGA,IAAM,wBAAwB;AAC9B,IAAM,oBAAoB;AAenB,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,WAAW,SAAU,KAAI,SAAS,UAAU,UAAU,iBAAiB;AAC7E;AAEF,UAAU,MAAM;AAChB,UAAU,UAAU;AACpB,mBAAmB,SAAS;","names":[]}