class-validator-extended
Version:
Additional validators for class-validator.
34 lines (33 loc) • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MIN_BIGINT = void 0;
exports.MinBigInt = MinBigInt;
const class_validator_1 = require("class-validator");
const min_bigint_predicate_1 = require("./min-bigint.predicate");
/** @hidden */
exports.MIN_BIGINT = 'minBigInt';
/**
* Checks if the given value is a [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
* not less than `minimum`.
*
* #### Example
* ```typescript
* // Ensure the value is greater than 9000.
* @MinBigInt(9_001)
* overNineThousand: BigInt
* ```
*
* @category BigInt
* @param minimum The minimum allowed value.
* @param options Generic class-validator options.
*/
function MinBigInt(minimum, options) {
return (0, class_validator_1.ValidateBy)({
name: exports.MIN_BIGINT,
constraints: [minimum],
validator: {
validate: (value, _arguments) => (0, min_bigint_predicate_1.minBigInt)(value, minimum),
defaultMessage: (0, class_validator_1.buildMessage)(eachPrefix => `${eachPrefix}$property must not be less than $constraint1`, options),
},
}, options);
}