in reply to New Module Consideration?

IMHO - the most missing feature in the *Validate* modules is one that allows simple/clear expression of $x+$y == 42 type constraints, so this is the feature that would most justify a new module. Most (Data::Validate anyway) seem geared for required/optional tests.

you should also look at Params::Validate.

Ive yet to use any of the *validate* modules, but this one is on the top of my short-list. It has - to me - an intuitive interface thats geared for validating args to a function. It handles both named-params and positional, tho named is (always) clearer.

sub snafu {
   validate (@_, { foo => 'SCALAR', # foo must be scalar
                   arry => 'ARRAY', });
   # func body here
}

Replies are listed 'Best First'.
Re: Re: New Module Consideration?
by Flame (Deacon) on Jan 03, 2003 at 03:38 UTC
    "$x+$y == 42"? I'm interested in what you're saying, but you lost me, what would you be attempting to validate?



    My code doesn't have bugs, it just develops random features.

    Flame ~ Lead Programmer: GMS | GMS

      As an example, if you've got a form that says "rank the following ten items from most important (1) to least important (9)", they must sum to 45.

      Completly unrelatedly, what I really think the world needs is a form validation module that will both validate the form after it's submitted for security, and generate JS to validate the form before submittion to be nice for the user.


      Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

        Completly unrelatedly, what I really think the world needs is a form validation module that will both validate the form after it's submitted for security, and generate JS to validate the form before submittion to be nice for the user.

        Actually, what the world needs is less of these CGI.pm-style modules that try and do too much at once. Separate tasks, like generating javascript and doing server-side validation, should be in separate modules. Going the other way results in reduced reusability in the components and does nothing to solve the problem.

        But that's just another anonymous monk's opinion.

        I could still rank them 45 0 0 0 0 0 0 0 0. If this is permissible, why would it be unacceptable to make it 90 0 0 0 0 0 0 0 0? Of course, that just shows the example is bad and does not really discredit the idea.

        Makeshifts last the longest.

        Hmm, that's an interesting idea, I'll see if I can think of a way to incorperate it... Thanks



        My code doesn't have bugs, it just develops random features.

        Flame ~ Lead Programmer: GMS | GMS

        I have the solution to this suggestion. I'm changing the way you select your element to optionally be an array ref. eg: -element => 'hi'; or -element => ['hi1','hi2'] will both work.

        Custom tests will have the option of accepting arguments one at a time, or several at once, I plan to use prototyping for this.

        Comments, suggestions?



        My code doesn't have bugs, it just develops random features.

        Flame ~ Lead Programmer: GMS | GMS

      '"$x+$y == 42"? I'm interested in what you're saying, but you lost me, what would you be attempting to validate?'

      The meaning of life, the universe and everything, perhaps? ;)

      Or do you think that's a little too ambitious for Perl?

      __________
      "Every program has at least one bug and can be shortened by at least one instruction -- from which, by induction, one can deduce that every program can be reduced to one instruction which doesn't work." -- (Author Unknown)