0.3.1 • Published 5 years ago

@sadbox/walledator v0.3.1

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

Version License Dependencies Bundle Size Build Status Codecov

Walledator

An environment agnostic nano-robot to perform schema validations.

Install

yarn add @sadbox/walledator

or

npm install -S @sadbox/walledator

Usage

import Q from '@sadbox/walledator';

const isFree = email => request('/email-is-free', email);

const schema = Q.shape({
  email: Q.email.custom({ key: 'taken', isFree }).required,
  password: Q.string.match(regex).size({ min: 8 }).required,
});

// server
schema.validate(request.body);

// client
schema.defineMessages({
  'shape.email.email': 'is not an email',
  'shape.email.taken': 'is already taken',
  'shape.password.match': 'contains invalid symbols',
  'shape.password.size': 'does not match the size limitations',
  'shape.required': 'is required',
});
schema.validate(form.values, { humanize: true });
0.3.1

5 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago