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

RJSF empty string/null field issues #1612

Open
marcellmueller opened this issue May 6, 2024 · 0 comments
Open

RJSF empty string/null field issues #1612

marcellmueller opened this issue May 6, 2024 · 0 comments
Labels

Comments

@marcellmueller
Copy link
Contributor

This is a tricky issue that we have some band aid fixes that have caused other issues.

  • In URL widget we added a fix to change an empty string to undefined since empty string was causing erroneous validation. This would happen if a user added a URL and saved the form, then deleted it. Our backend would then save and return an empty string which would cause erroneous validation issues.
  • The previous fix we added prevents a URL field from being required.
  • In our user_operator Django Ninja schema we default the trade_name and website fields to empty string where everything else defaults to None. I believe this was added due to issues with these being optional and RJSF. Changing them to None like most of the other fields and removing the URLWidget fix gives an RJSF null field error.

Saving all these empty strings in the database could cause weird validation bugs further down the road. We probably should not default to empty string.

One possible solution along with cleaning up the Django ninja schema is to clean our form data in FormBase before we feed it into the form. Even though most of our form data is flat this would probably require a recursive function that searches arrays (parent operators) since they will have nested data. We would want it to remove keys with empty string, null or undefined values but keep other falsy values such as false or 0.

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

No branches or pull requests

1 participant