flexdinesh/typy

[Feature] Include custom types in schema validation

Open

#17 创建于 2019年1月14日

在 GitHub 查看
 (0 评论) (4 反应) (0 负责人)JavaScript (21 fork)github user discovery
enhancementhelp wanted

仓库指标

Star
 (226 star)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南