vitalics / ajv-ts

First-class ajv typescript JSON-schema builder inspired from Zod
https://www.npmjs.com/package/ajv-ts
MIT License
39 stars 3 forks source link

Feature: strict number validation #65

Closed vitalics closed 1 week ago

vitalics commented 1 week ago

We make validation for number type, format, minValue and maxValue fields. That means we handle it on our side so you get an error for invalid values.

Examples:

s.number().format('float').int() // error in type!
s.int().const(3.4) // error in type!
s.number().int().format('float') // error in format!
s.number().int().format('double') // error in format!

// ranges are also check for possibility

s.number().min(5).max(3) // error in range!
s.number().min(3).max(5).const(10) // error in constant!