flexdinesh/typy

[Feature] Include custom types in schema validation

Open

#17 opened on Jan 14, 2019

View on GitHub
 (0 comments) (4 reactions) (0 assignees)JavaScript (21 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (226 stars)
PR merge metrics
 (PR metrics pending)

Description

Like so:

import { addCustomTypes } from 'typy';

addCustomTypes({
  isFirstName: input => 3 <= input.length && input.length <= 15,
  isLastName: input => 3 <= input.length && input.length <= 15
});
import t, { Schema } from 'typy';

const schema = { 
  firstName: Schema.isFirstName,
  lastName: Schema.isLastName
}

t({
  firstName: 'John',
  lastName: 'Doe'
}, schema);

Contributor guide