flexdinesh/typy

[Feature] Include custom types in schema validation

Open

#17 opened on 2019年1月14日

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)

説明

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

コントリビューターガイド