logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Declare::Constraints::Simple::Library::Array - Array Constraints

Author

       Robert 'phaylon' Sedlacek "<phaylon@dunkelheit.at>"

Constraints

HasArraySize([$min,[$max]])
       With $min defaulting to 1. So a specification of

         my $profile = HasArraySize;

       checks for at least one value. To force an exact size of the array, specify the same values for both:

         my $profile = HasArraySize(3, 3);

   OnArrayElements($key=>$constraint,$key=>$constraint,...)
       Applies the the $constraints to the corresponding $keys if they are present. For required keys see
       "HasArraySize".

   OnEvenElements($constraint)
       Runs the constraint on all even elements of an array. See also "OnOddElements".

   OnOddElements($constraint)
       Runs the constraint on all odd elements of an array. See also "OnEvenElements".

Description

       This module contains all constraints that can be applied to array references.

Name

       Declare::Constraints::Simple::Library::Array - Array Constraints

See Also

       Declare::Constraints::Simple, Declare::Constraints::Simple::Library

Synopsis

         # accept a list of pairs
         my $pairs_validation = IsArrayRef( HasArraySize(2,2) );

         # integer => object pairs
         my $pairs = And( OnEvenElements(IsInt),
                          OnOddElements(IsObject) );

         # a three element array
         my $tri = And( HasArraySize(3,3),
                        OnArrayElements(0, IsInt,
                                        1, IsDefined,
                                        2, IsClass) );

See Also