You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
This is a tricky issue that we have some band aid fixes that have caused other issues.
user_operator
Django Ninja schema we default thetrade_name
andwebsite
fields to empty string where everything else defaults toNone
. I believe this was added due to issues with these being optional and RJSF. Changing them toNone
like most of the other fields and removing theURLWidget
fix gives an RJSFnull
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 asfalse
or0
.The text was updated successfully, but these errors were encountered: