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.8 kB
Source Map (JSON)
{"version":3,"sources":["../src/asserts/bigint/bigintMinExcluded.ts"],"sourcesContent":["import { setToDefaultLocale } from '../../translationMap';\nimport type { ExceptionContext, RequiredValidation } from '../../core';\n\nconst bigintMinExcludedErrorMessage = 'The received value is less than or equal to expected';\nconst bigintMinExcludedErrorKey = 'bi:minExcluded';\n\n/**\n * @description Asserts that a bigint value is strictly greater than a specified minimum value (i.e., the minimum value is excluded).\n * @param {bigint} expected The minimum 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 less than or equal to the expected minimum value.\n * @example\n * const schema = bigint().custom(bigintMinExcluded(10n));\n * parseOrFail(schema, 11n); // Valid\n * parseOrFail(schema, 10n); // Throws an error: 'The received value is less than or equal to expected'\n * parseOrFail(schema, 9n); // Throws an error: 'The received value is less than or equal to expected'\n *\n * @translation Error Translation Key = 'bi:minExcluded'\n */\nexport const bigintMinExcluded =\n (expected: bigint): RequiredValidation =>\n (received: bigint, ctx: ExceptionContext) => {\n if (expected >= received) ctx.addIssue(expected, received, bigintMinExcludedErrorKey);\n };\n\nbigintMinExcluded.key = bigintMinExcludedErrorKey;\nbigintMinExcluded.message = bigintMinExcludedErrorMessage;\nsetToDefaultLocale(bigintMinExcluded);\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":[]}