Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Functions #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Custom Functions #50

wants to merge 2 commits into from

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