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.82 kB
Source Map (JSON)
{"version":3,"sources":["../src/asserts/bigint/bigintMaxExcluded.ts"],"sourcesContent":["import { setToDefaultLocale } from '../../translationMap';\nimport type { ExceptionContext, RequiredValidation } from '../../core';\n\nconst bigintMaxExcludedErrorMessage = 'The received value is greater than or equal to expected';\nconst bigintMaxExcludedErrorKey = 'bi:maxExcluded';\n\n/**\n * @description - Asserts that a bigint value is strictly less than a specified maximum value (i.e., the maximum value is excluded).\n * @param {bigint} expected - The maximum allowable value, which is excluded.\n * @returns {RequiredValidation} - A validation function that takes a received bigint and an exception context.\n * @throws {ValidationError} if the received value is greater than or equal to the expected maximum value.\n * @example\n * const schema = bigint().custom(bigintMaxExcluded(100n));\n * parseOrFail(schema, 99n); // Valid\n * parseOrFail(schema, 100n); // Throws an error: 'The received value is greater than or equal to expected'\n * parseOrFail(schema, 101n); // Throws an error: 'The received value is greater than or equal to expected'\n *\n * @translation Error Translation Key = 'bi:maxExcluded'\n */\nexport const bigintMaxExcluded =\n (expected: bigint): RequiredValidation =>\n (received: bigint, ctx: ExceptionContext) => {\n if (expected <= received) ctx.addIssue(expected, received, bigintMaxExcludedErrorKey);\n };\n\nbigintMaxExcluded.key = bigintMaxExcludedErrorKey;\nbigintMaxExcluded.message = bigintMaxExcludedErrorMessage;\nsetToDefaultLocale(bigintMaxExcluded);\n"],"mappings":";;;;;AAGA,IAAM,gCAAgC;AACtC,IAAM,4BAA4B;AAe3B,IAAM,oBACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,YAAY,SAAU,KAAI,SAAS,UAAU,UAAU,yBAAyB;AACtF;AAEF,kBAAkB,MAAM;AACxB,kBAAkB,UAAU;AAC5B,mBAAmB,iBAAiB;","names":[]}