Comments (13)
I could be mistaken, but as far as I can see, field level validation does not handle asynchronous validation. Is that correct?
When I pass an async function (or a function which returns a Promise), AOR complains about the validation error not being a React node:
Failed prop type: Invalid prop `errorText` supplied to `TextField`, expected a ReactNode.
in TextField (created by TextInput)
in TextInput (created by ConnectedField)
Uncaught Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. Check the render method of `TextField`.
Redux form supports an asyncValidation
function, is there a way we can declare asyncValidation
in our Create
or Update
components?
from react-admin.
@edorivai well I got it working... on field level...
here is the example :
<SimpleForm asyncValidate={asyncValidate} asyncBlurFields={[ 'firstName' ]}> <TextInput source="firstName" /> </SimpleForm>
You pass in the asyncValidate to the Form component, and the asyncBlurFields you pass in the fields that will trigger the asyncValidation.
from react-admin.
Also experiencing the same issue as @edorivai
from react-admin.
Admin-on-rest relies on redux-form for form validation, and redux-for supports asynchronous validation. So in theory it's not hard to do.
Until we implement it, feel free to use your own <Edit>
or <Create>
component.
from react-admin.
+1 for async validation support.
If the validation functions could return Promises to indicate async validation, that would be a simple and effective enough API.
from react-admin.
Fixed by #420
from react-admin.
As for as I know, async validation does not work at the field level, but there is a way to hook into the global async validation. See the tip at: https://marmelab.com/admin-on-rest/CreateEdit.html#global-validation
The gist is:
<TabbedForm asyncValidate={yourCustomAsyncValidationFunction}>
...
</TabbedForm>
from react-admin.
having the same issue as @edorivai and @sampeka.
when you pass asyncValidate function to the validate prop, it returns a promise.
How do we pass the fulfilled result to the redux-form?
from react-admin.
@fzaninotto now In the react 3.0 whether to support async validation?now did not use redux-form.so ,can async validation of server be realized?
from react-admin.
I suppose, since you can pass whatever props you want to the SimpleForm
and they'll get passed to the react-final-form. I invite you to try!
from react-admin.
@fzaninotto you mean can use props 'asyncValidate' in SimpleForm of 3.0?
from react-admin.
I mean you have to look at how react-final-form handles it. I have no idea how it works, we don't need it for now, so you'll have to do the digging.
from react-admin.
@fzaninotto ok i have try ,thanks a lot
from react-admin.
Related Issues (20)
- DataInput with parse function: date.toISOString is not a function HOT 3
- Add Repobeats (metrics) to README
- TabbedForm has Error: Maximum update depth exceeded. HOT 7
- `<Autocomplete onCreate>` briefly displays wrong option name
- ra-data-graphql: faulty deprecation warning regarding `override` HOT 2
- Current page of list view should not be silently preserved HOT 1
- Cli does not show anything HOT 3
- Webstorm does not able to read .eslintrc.js HOT 1
- TabbedForm has Error: Maximum update depth exceeded HOT 4
- NumberInput fails to parse not a number input value and which causes input label overlaying non existing value HOT 1
- [CRM Demo] When using modals for show and edit views, the data is not updated in show views
- Documentation search is broken on versions < latest (v5.05) HOT 1
- Nested ArrayInput saves all values to undefined HOT 1
- Running dist code on production not working as expected HOT 3
- notification sent from user account to administrator account react js HOT 4
- rowClick is called automatically HOT 3
- [useTranslatable::getRecordPath] - record with "null" value causes a client error | Edit with <TranslatableInputs> HOT 1
- Running on Next.js 14 with App Router doesn't seem to allow for path based URLs HOT 1
- ArrayInput + SimpleFormIterator no working correctly inside the TranslatableInputs component in React Admin 5.1 HOT 3
- Incorrect index display in PrevNextButtons component on pagination navigation HOT 1
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 react-admin.