Skip to content

Conversation

yedidmh
Copy link

@yedidmh yedidmh commented Nov 23, 2016

Solution for #43.

Adds support for Function.custom() which accepts a user-defined function and passes it the field value, expecting an object to be returned with the fields valid and msg.

var validate = schema({
  'birthday': Function.custom(x => ( { valid: moment(x).isValid(), msg: 'Invalid datetime' } ))
});

Not a pure predicate because I want to allow defining an error message.

@tizmagik
Copy link

This looks useful. Any chance to get this in @molnarg ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants