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

貢獻者指南