-
Notifications
You must be signed in to change notification settings - Fork 933
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
Feat: exposes context on mixed.test function and add originalValue to context #1021
Conversation
README.md
Outdated
@@ -706,26 +706,27 @@ use the alternate signature to provide more options (see below): | |||
let jimmySchema = string().test( | |||
'is-jimmy', | |||
'${path} is not Jimmy', | |||
value => value === 'jimmy', | |||
value, context => value === 'jimmy', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value, context => value === 'jimmy', | |
(value, context) => value === 'jimmy', |
Hi @abnersajr thanks for the PR. It looks like this PR updates the docs but doesn't implement the feature. Is that intentional or did a commit go missing somewhere? |
Sorry @jquense. Definitely something was misssed in my commits. I'm gonna check it ASAP. and thanks for the quick review. |
What happened to this? |
@jquense Are you're still willing to merge this? If there is something missing, I can fork this branch and add it. |
@jquense ping |
can you resolve the conflict @abnersajr ? |
@jquense sure. I'm gonna do this. |
@jquense merge is done. Solved the conflicts adding to the sync and async version. |
thanks! |
\o/ can we get a new minor release with this, please? 😄 |
@jquense Actually, I think this might require to bump the version up to |
This PR fixes two issues: #207 and #1007.
The discussions suggest having
originalValue
exposed in some way. Exposing as the second argument was one of the suggestions.Following the API and suggestion from @jquense, would be better to have this
originalValue
into thethis
context.In previous versions, you can't use arrow functions too, because it's being used
.call(ctx...)
.With these changes, you can use both ways. The
this
context is now exposed too as a second argument.Eg:
mixed.test('name', 'test name', (value, ctx) => ctx.originalValue)
Also edited Type Definitios: DefinitelyTyped/DefinitelyTyped#47069