0.2.10 ā€¢ Published 5 years ago

veni v0.2.10

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Veni

Painless validation for TypeScript šŸ§˜ā€ā™€ļøšŸ§˜ā€ā™‚ļø

Build Status npm module

Installation

npm i veni
yarn add veni

Usage

import { V, validate } from 'veni';

enum Gender {
  Male = 'Male',
  Female = 'Female',
  gender: V.enum().values<Gender>(Object.values(Gender)),
}

const schema = V.object().keys({
  username: V.string()
    .min(3)
    .max(30),
  firstName: V.string().optional(),
  lastName: V.string().optional(),
  password: V.string().regex(/^[a-zA-Z0-9]{3,30}$/),
  birthyear: V.number()
    .integer()
    .min(1900)
    .max(2013),
});

const data = {
  username: 'john',
  password: 'password',
  birthyear: '2000',
  email: 'john@example.com',
  gender: 'male'
};

const user = validate(data, schema, 'user');

ā€¼ļø Properties are inferred automatically.

alt autocomplete

API Reference

Check API reference here

Features

  • Written and compatible with TypeScript in 100%.
  • API is highly inspired on joi, but simplified.
  • Types are automatically inferred based on schema. Solves "double annotation" problem.
  • No dependencies.
  • Minimal bundle size.
  • Very easy to extend, and add custom validation rules. Check here.

MIT

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

6 years ago

1.0.0

6 years ago