added bigInteger custom validator

This commit is contained in:
Pau 2025-04-07 23:31:25 +02:00
parent 0c146c201e
commit ff23689c0e
1 changed files with 3 additions and 1 deletions

View File

@ -3,9 +3,11 @@ import { check } from 'express-validator'
const varChar = (field, { max = 255 } = {}) => check(field).isString().trim().isLength({ min: 1, max }).withMessage(`|${field}| must be a string with a length between 1 and ${max}`) const varChar = (field, { max = 255 } = {}) => check(field).isString().trim().isLength({ min: 1, max }).withMessage(`|${field}| must be a string with a length between 1 and ${max}`)
const integer = field => check(field).isInt({min: Number.MIN_SAFE_INTEGER, max: Number.MAX_SAFE_INTEGER}).withMessage(`|${field}| must be an integer`) const integer = field => check(field).isInt({min: Number.MIN_SAFE_INTEGER, max: Number.MAX_SAFE_INTEGER}).withMessage(`|${field}| must be an integer`)
const uuid = field => check(field).isUUID('all').withMessage(`|${field}| must be a valid UUID`) const uuid = field => check(field).isUUID('all').withMessage(`|${field}| must be a valid UUID`)
const bigInt = field => check(field).isBigInt().withMessage(`|${field}| must be a valid BigInt`)
export { export {
integer, integer,
uuid, uuid,
varChar, varChar,
} bigInt
}