I need to validate number 18.2
with class-validator. On current stage I know how to validate only decimal places:
export class PaymentBasicData {
/**
* Transaction amount.
*/
@Expose()
@IsNotEmpty()
@IsNumber({ maxDecimalPlaces: 2 })
@Min(0.01)
@Max(999999999999999999.99)
public amount: number;
}
I should validate a number
with 18 numbers before dot and 2 numbers after dot. How it should looks like?
For the digits part
class-validator
has a@IsDecimal
validation decorator you can use and it accepts options.For what I know you cannot validate before coma (or point) digits, the maximum value you already used should work.