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

How to get field value in message creator function? #65

Open
zoxon opened this issue Mar 14, 2020 · 1 comment
Open

How to get field value in message creator function? #65

zoxon opened this issue Mar 14, 2020 · 1 comment

Comments

@zoxon
Copy link

zoxon commented Mar 14, 2020

Thank you for this library.
I'm trying to create a custom validator using createValidator helper
In the message I need use current value, how to achieve this?

It looks something like this

const myValidator = createValidator(
  message => value => message,
  (field, value) => `${field} has value ${value}`
);
@zoxon
Copy link
Author

zoxon commented Mar 16, 2020

Experiments today and find that.
Return function instead of string, and apply value in validator implementation.
What pitfalls are there?

const myValidator = createValidator(
  message => value => message(value),
  (field) => (value) => `${field} has value ${value}`
);

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

No branches or pull requests

1 participant