Don't ask to ask, just ask | |
PerlMonks |
RFC: Data::FormValidator enhancement proposalby markjugg (Curate) |
on Feb 12, 2002 at 15:48 UTC ( [id://144887]=perlmeditation: print w/replies, xml ) | Need Help?? |
Hello,
I'm working on adding an addition to the Data::FormValidator module and want to get your feedback on it. The primary issue I'm addressing at the moment could be summarized as "missing optional fields disappear" Here's a more detailed explanation: If a field is marked as optional in the validation profile, and is present but empty in the input hash, the field does not appear anywhere in the resulting output-- it's not marked as valid, missing, invalid or unknown. Most of the time this doesn't matter, but there is important case that it does: If you are using the profile for an "update" web form, and the initial data set contains some text, but the user removes it, the field does not appear in the %valid hash returned, so if you pass that directly to DBIx::Abstract to update a database for example, that field won't get updated to be empty in the database. This can be worked around with some additional perl, but it's annoying to have to do it every time. What I plan to do is to add an option that allows missing optional field to be classified as valid. This actually seems like a more intelligent default behavior to me, although I'm hesitant to make this a true default to avoid breaking existing applications that might rely on this subtle distinction. Here's the interface I have in mind. Each input specification would support an additional key:
This would default to zero, the old behavior, and set to a true value to get the new behavior. Any suggestions on alternate ways to make this interface change this before I add it into the module? Thanks, -mark update: This has now been added to Data::FormValidator 1.8. Thanks for your feedback!
Back to
Meditations
|
|