Skip to content

Commit

Permalink
clarified refineType usage
Browse files Browse the repository at this point in the history
  • Loading branch information
tlivings committed Jan 10, 2018
1 parent 911a8db commit c99bcf4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,19 @@ schema.validate(something, function (error, value) {

### Refine Type

You can use the refine type function to help refine types based on `type` and `format`.
You can use the refine type function to help refine types based on `type` and `format`. This will allow transforming a type for lookup against the custom `types`.

```javascript
const schema = Enjoi({
type: 'string',
format: 'email'
}, {
types: {
email: Joi.string().email()
},
refineType(type, format) {
if (type === 'string' && format === 'email') {
return Joi.string().email();
return 'email';
}
}
});
Expand Down

0 comments on commit c99bcf4

Please sign in to comment.