typy
typy copied to clipboard
feat: addCustomTypes to be used as a Schema
feat Include custom types in schema validation, request in issue: flexdinesh/typy#17
Now we can do this:
addCustomTypes({
isObjectId: input => (/^[\w\d]{24}$/g.test(String(input))),
});
t({
Rank: 1,
Name: 'Typy',
ObjectId: '5349b4ddd2781d08c09890fa'
}, {
Rank: Schema.Number,
Name: Schema.String,
ObjectId: Schema.isObjectId
});
I really like this lib and I very happy to contribute for it. If you liked my PR, please put the hacktoberfest-accepted label in that. Thanks hacktoberfest site