typy icon indicating copy to clipboard operation
typy copied to clipboard

feat: addCustomTypes to be used as a Schema

Open filiafobico opened this issue 4 years ago • 2 comments

feat Include custom types in schema validation, request in issue: flexdinesh/typy#17

filiafobico avatar Oct 19 '20 01:10 filiafobico

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

filiafobico avatar Oct 19 '20 10:10 filiafobico

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

filiafobico avatar Oct 19 '20 10:10 filiafobico