class-validator icon indicating copy to clipboard operation
class-validator copied to clipboard

feature: IsSafeInit validator

Open AcherTT opened this issue 1 year ago • 1 comments

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);
}

AcherTT avatar Aug 02 '23 09:08 AcherTT

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.

braaar avatar Jan 11 '24 07:01 braaar