class-validator
class-validator copied to clipboard
feature: IsSafeInit validator
Description
I need a secure JavaScript validator for validating "safe int" type.
example
class MyClass {
@IsSafeInt()
someProperty: number;
}
Proposed solution
use Number.isSafeInteger.
export function isSafeInt(val: unknown): val is Number {
return typeof val === 'number' && Number.isSafeInteger(val);
}
I'm moving this to the discussion tab, as we are trying to keep the issue count low. Please see this issue for an explanation.