Comments (12)
@zysktomasz You want to pass a function that can manipulate related rules if you see the documentation of related field you can see that you can pass another element to the array as a callback that get related-field data as input and must return a value.
Field().custom(["#someField", x => x.Uppercase()], callbackValidator);
from v4f.
@reyx7 That doesn't work. The callbackValidator never gets called. Any ideas?
from v4f.
@chrisneal can you make a sandbox for these issues
from v4f.
@reyx7 https://codesandbox.io/s/3km1h
from v4f.
@chrisneal it works correctly, the costum rule only takes an array with two elements the ["Field Name", callback_function], check out the API reference for more information.
If your problem is not resolved open a new issue with detailed pieces of information, that will help to workaround the issue.
@chrisneal thanks for your feedback
from v4f.
@reyx7 In your reply to zysktomasz above, you mention that you can use a custom field with a callback, and then an additional callback.
Field().custom(
[
"#someField",
x => x.Uppercase()
],
callbackValidator
);
In my sandbox example, I have:
Field().custom(
[
"#endedAt",
endedAt => {
console.log(endedAt);
return true;
}
],
startedAt => {
console.log(startedAt);
return true;
}
)
So are you saying that your reply to zysktomasz is incorrect?
from v4f.
@chrisneal Please read the documentation carefully.
from v4f.
@reyx7 I have... Could you at least answer my question?
from v4f.
@chrisneal please give some time to the documentation and try to understand the library,
and try the examples in the documentation.
from v4f.
@reyx7 I have read the documentation, and looked through the code. I was purely referencing your comment above. I can't see any evidence of it working the way it does above, but you're the author, and you're the one that gave the example code. So I'm assuming that the code in your comment above is wrong?
from v4f.
@chrisneal can you please make a clear example in the sandbox , the library is fine all rules are well tested you have miss understood something.
from v4f.
@reyx7 I posted a sandbox link above (https://codesandbox.io/s/3km1h), as well as called out the specific code from my sandbox here:
#57 (comment)
from v4f.
Related Issues (20)
- Add callback to apply to value of cross field rule
- Change the name of when to apply to make more sense
- Fix Required and Optional rules
- Add new sets of rules for v4f
- Improve and Refactor code base
- Publish to open source community
- Add Message error template for value and field name
- Add Async Validation
- Add Verbose boolean Validation
- Fix Nested Schema with async options and nested schema with message template
- Create Examples
- Questions about the future HOT 4
- Add publish to npm pipline
- Improve rollupjs config file
- Fix Security issues CVE-2019-12043
- Move Examples from this repo to it own repo
- Improve the Readme
- Fix jest unittest
- Is there a way to do async username checks? [Question]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v4f.