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
I have a form with optional fields using for instance the email regEx. This works fine if you validate it and do not fill out the optional email fields but once you have filled it out and want to clear it in the next update it does of course not get cleared as empty fields are removed by default. If you set removeEmptyStrings to false then it won't pass the validation as it is not a valid email address. Does anyone know what the solution for that is if you want an empty string in the database or want the attribute removed in the database?
BTW, I am using both simpl-schema and collection2.
The text was updated successfully, but these errors were encountered:
@edwinhaver I think what you are saying is that there should be some option that makes an empty string be valid when regEx option is used and the field is optional. That seems useful.
There are ways that you can work around this, such as by writing your own regular expression that allows empty strings or by adjusting all the empty strings to be null before inserting/validating.
I just dealt with this here and wanted to share some thoughts and a workaround. I looked into introducing this into simpl-schema but there is a test case explicitly written to not provide this functionality. Not sure what issue 409 (conflict on put?) but here's a workaround that I use to make this work.
Happy to introduce a fix into simpl-schema but definitely going to need a bit more clarity around that 409 test case to make sure it is introduced correctly. In the time being, the workarounds are more then fine and there are plenty of approaches to making this work as is.
I have a form with optional fields using for instance the email regEx. This works fine if you validate it and do not fill out the optional email fields but once you have filled it out and want to clear it in the next update it does of course not get cleared as empty fields are removed by default. If you set removeEmptyStrings to false then it won't pass the validation as it is not a valid email address. Does anyone know what the solution for that is if you want an empty string in the database or want the attribute removed in the database?
BTW, I am using both simpl-schema and collection2.
The text was updated successfully, but these errors were encountered: