Closed jaysson closed 8 years ago
You should be able to access email via this.source.email
, this.source
contains the source input object being validated.
I just plugged it into a test and it is available as expected, hope it works for you.
See: https://github.com/tmpfs/async-validate#rule
Note that the state object is also available for passing data between rules so if you only wanted it available to the token validation you could put it in this.state
and access it via this.state
(potentially conditionally).
Let me know if this solves it for you. Ta.
Oops missed your point on source
, double checking now...
Hmmm, it should not be removed from source
- I've added a test case that verifies that the source contains the email
field from a previous rule, see:
https://github.com/tmpfs/async-validate/commit/8e109fdef4a7ce04922109c6f5455089e3cf6199
If it's still not working let me see the output of console.log(this)
in the token rule function.
Seems to be working now.
I did npm update in the meanwhile.
Cool, thanks for letting me know. Closing as not an issue but re-open if you experience the same problem again.
I am trying to validate a token against a user account, fetched by email.
I tried accessing
this.source
but it only contains the token while validating token. Email is removed after email validation.In general, I can think of many use cases where you want to validate a field against another. For example,
end_date > start_date
.How do I do this?