flexdinesh/typy

[Feature] Include custom types in schema validation

Open

#17 aberto em 14 de jan. de 2019

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

Métricas do repositório

Stars
 (226 stars)
Métricas de merge de PR
 (Métricas PR pendentes)

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);

Guia do colaborador