We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Given the following form component:
const Form = withTheme(AntDTheme); <Form id="inner-form" // @ts-ignore ref={(formData) => myForm = formData} schema={data} onChange={ (e) => { console.log("Event:", e) } } validate={(formData, errors)=>{ return errors }} uiSchema={uiSchema} showErrorList={false} > <Button hidden={false} onClick={()=>console.log("myform:", myForm)}> Action </Button> </Form>
I'm trying to get errors from myForm.validate(). But it returns:
myForm.validate()
{ "errors": [], "errorSchema": { "__errors": [], "firstName": { "__errors": [] }, "date1": { "__errors": [] }, "telephone": { "__errors": [] }, "filesAccept": { "__errors": [] } } }
My schema:
{ "id": 1, "name": "lorem ipsum", "type": "object", "required": ["firstName", "filesAccept"], "properties": { "firstName": { "type": "string", "title": "First name", "pattern": "foobar" }, "date1": { "type": "string", "format": "date" }, "telephone": { "type": "string", "title": "Telephone", "minLength": 10 }, "filesAccept": { "type": "array", "title": "Arquivos", "items": { "type": "string" } } } }
In other words, I would like to validate form fields before clicking submit button. Is it possible?
myForm
I would expect errors object in validate prop to indicate that "First Name" field of the form, for example, does not follow the pattern required.
errors
validate
Function used in validate prop never shows errors
You can usually get this information in your package.json or in the file URL if you're using the unpkg one.
package.json
"@rjsf/core": "^4.0.1" "@rjsf/antd": "^4.0.1"
"@rjsf/core": "^4.0.1"
"@rjsf/antd": "^4.0.1"
The text was updated successfully, but these errors were encountered:
We use jsonschema to validate our schemas. https://www.npmjs.com/package/jsonschema
jsonschema
const validator = new Validator() const sectionErrors = validator.validate(state, schema)
Sorry, something went wrong.
Hi, @a3957273 thank you. I ended up using https://www.npmjs.com/package/ajv
const ajv = new Ajv({ allErrors: true }); addFormats(ajv as any); const validate = ajv.compile(schema);
Hi, @a3957273 thank you. I ended up using https://www.npmjs.com/package/ajv const ajv = new Ajv({ allErrors: true }); addFormats(ajv as any); const validate = ajv.compile(schema);
Anyway, I would expect react-jsonschema-form to validate its own data. AFAIK, it already uses ajv
Fixed in the v5 beta.9
Successfully merging a pull request may close this issue.
Prerequisites
Description
Given the following form component:
I'm trying to get errors from
myForm.validate()
. But it returns:My schema:
In other words, I would like to validate form fields before clicking submit button. Is it possible?
Steps to Reproduce
myForm
to global variable and then executemyForm.validate()
Expected behavior
I would expect
errors
object invalidate
prop to indicate that "First Name" field of the form, for example, does not follow the pattern required.Actual behavior
Function used in
validate
prop never shows errorsVersion
You can usually get this information in your
package.json
or in the file URL if you're using the unpkg one."@rjsf/core": "^4.0.1"
"@rjsf/antd": "^4.0.1"
The text was updated successfully, but these errors were encountered: