1.0.9 â€ĸ Published 4 years ago

overshom-valid v1.0.9

Weekly downloads
18
License
ISC
Repository
github
Last release
4 years ago

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.

1.0.9

4 years ago

1.0.7

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago