UNPKG

class-validator-extended

Version:
32 lines (31 loc) 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.POSITIVE_BIGINT = void 0; exports.PositiveBigInt = PositiveBigInt; const class_validator_1 = require("class-validator"); const positive_bigint_predicate_1 = require("./positive-bigint.predicate"); /** @hidden */ exports.POSITIVE_BIGINT = 'positiveBigInt'; /** * Checks if the given value is a [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) * greater than zero. * * #### Example * ```typescript * // Ensure the value is greater than 0. * @PositiveBigInt() * positiveNumber: BigInt * ``` * * @category BigInt * @param options Generic class-validator options. */ function PositiveBigInt(options) { return (0, class_validator_1.ValidateBy)({ name: exports.POSITIVE_BIGINT, validator: { validate: (value, _arguments) => (0, positive_bigint_predicate_1.positiveBigInt)(value), defaultMessage: (0, class_validator_1.buildMessage)(eachPrefix => `${eachPrefix}$property must be a positive BigInt`, options), }, }, options); }