0.0.1 • Published 3 years ago

@framed/scrub v0.0.1

Weekly downloads
14
License
ISC
Repository
-
Last release
3 years ago

Jazz

npm.io Documentation Status

Scrub

Scrub is a simple object validator.

import * as scrub from '@framed/scrub';

const personValidator = scrub.object({
  name: scrub.string({ transformString: ['trim', 'title'] }),
  age: scrub.number({ min: 18 }),
});

type PersonType = scrub.GetType<typeof personValidator>;

const validPerson: PersonType = {
  name: 'Homer Simpson',
  age: 39,
};

personValidator.validate(validPerson);
// { name: 'Homer Simpson', age: 39 }

Documentation

To install run npm i @framed/scrub.

Please read the documentation at https://scrub.readthedocs.io/en/latest/.