You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I would also benefit from the @isBigInt decorator.
The IsBigint decorator would check only if a given value is a type of a bigint, the same way as the IsInt decorator only checks if the value is an integer.
Here is an example of an implementation I'm currently using in my projects:
import{buildMessage,ValidateBy,ValidationOptions}from'class-validator';exportconstIS_BIGINT='isBigInt';/** * Checks if the value is a bigint. */exportfunctionisBigInt(val: unknown): val is Number{returntypeofvalue==='bigint';}/** * Checks if the value is a bigintt */exportfunctionIsBigInt(validationOptions?: ValidationOptions): PropertyDecorator{returnValidateBy({name: IS_BIGINT,validator: {validate: (value,args): boolean=>isBigInt(value),defaultMessage: buildMessage((eachPrefix)=>eachPrefix+'$property must be a bigint',validationOptions),},},validationOptions);}
Additionally to IsInt add a @IsBigInt decorator
The text was updated successfully, but these errors were encountered: