Skip to content
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

formData with an empty string is not flagged as a validation required field error message #3303

Closed
4 tasks done
dagda1 opened this issue Dec 19, 2022 · 5 comments
Closed
4 tasks done

Comments

@dagda1
Copy link
Contributor

dagda1 commented Dec 19, 2022

Prerequisites

What theme are you using?

material-ui

Version

^5.0.0-beta.14

Current Behavior

With the following schema:

{
  "title": "Contextualized errors",
  "type": "object",
  "required": ["firstName", "lastName"],
  "properties": {
    "firstName": {
      "type": "string",
      "title": "First name"
    },
    "lastName": {
      "type": "string",
      "title": "Last name"
    }
  }
}

And the following Form component with the firstName field set to undefined and lastName set to ''.

<div className="container-fluid">
  <Form
    validator={validator}
    schema={schema as any}
    showErrorList={false}
    noHtml5Validate
    uiSchema={{}}
    customValidate={undefined}
    formData={{
      firstName: undefined,
      lastName: ''
    }}
    omitExtraData={false}
  />
</div>

firstName is recognised as a required field validation error, but lastName is not:

form

Expected Behavior

Any field with an initial formData value of '' should trigger validation of required fields.

Steps To Reproduce

  1. git clone git@github.com:dagda1/rjsf-example-5.git
  2. yarn install
  3. yarn start

I tried to create this codesandbox but I get the following error which does not happen when running the code outside codesandbox.

Error: Cannot find module 'ajv/dist/compile/codegen'

Environment

- OS:osx 12.6
- Node:16.17.0
- npm: 8.19.2

Anything else?

No response

@dagda1 dagda1 added bug needs triage Initial label given, to be assigned correct labels and assigned labels Dec 19, 2022
@dagda1 dagda1 changed the title formData with an empty string is not flagged as a validation error message formData with an empty string is not flagged as a validation required field error message Dec 19, 2022
@heath-freenome
Copy link
Member

This may be a duplicate of #3260 ... Which version of the validator are you using, ajv6 or ajv8?

@heath-freenome heath-freenome added awaiting response and removed needs triage Initial label given, to be assigned correct labels and assigned labels Dec 19, 2022
@dagda1
Copy link
Contributor Author

dagda1 commented Dec 19, 2022

Which version of the validator are you using, ajv6 or ajv8?

I'm using ajv8

@heath-freenome
Copy link
Member

heath-freenome commented Dec 19, 2022

Then it is likely an issue we are working on fixing related #3260

@dagda1
Copy link
Contributor Author

dagda1 commented Dec 20, 2022

@heath-freenome using the @rjsf/validator-ajv6 validator has the validations working as before.

@heath-freenome
Copy link
Member

Ok, watch #3260 and when we release the fix, go ahead and switch back to the ajv8 version. Closing this as a dup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants