flexdinesh/typy

[Feature] Include custom types in schema validation

Open

#17 ouverte le 14 janv. 2019

Voir sur GitHub
 (0 commentaires) (4 réactions) (0 assignés)JavaScript (21 forks)github user discovery
enhancementhelp wanted

Métriques du dépôt

Stars
 (226 stars)
Métriques de merge PR
 (Métriques PR en attente)

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

Guide contributeur