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:

# can you think of a shorter way to express this? missing_optional_fields_are_valid => 1

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!


In reply to RFC: Data::FormValidator enhancement proposal by markjugg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.