1.0.9 âĸ Published 4 years ago
overshom-valid v1.0.9
overshom-valid
Powerful TypeScript validation
- đĒ Completely typed runtime validation with TypeScript.
- đ§ Full intellisense support.
[ âšī¸, âšī¸, âšī¸ ]
Accumulated errors = see all validation errors at once.- đ Breadcrumbs-enhanced errors let you understand exact key failed validation.
- â Intuitive schema definitions and clear return type.
- đ Easily customizable.
- đĢ Zero dependecy.
Installation
yarn add overshom-valid
# or
npm i overshom-valid
Usage
import { v } from 'overshom-valid'
enum USER_ROLE {
USER = 'USER',
ADMIN = 'ADMIN',
}
const UserDto = v.class({
login: v
.String()
.min(4)
.max(16)
.pattern(/^\w+$/),
role: v.Object({
type: v.Enum(USER_ROLE),
}),
avatar: v
.String()
.optional(),
})
const user = new UserDto(`{
"login": "overshom",
"role": {
"type": "ADMIN"
}
}`)
More use cases
Inspect *.spec.ts
files inside ./src/
directory to see more use cases of validations.