Data::Validation::Constraints - Test data values for conformance with constraints
use Data::Validation::Constraints; %config = ( method => $method, %{ $self->constraints->{ $id } || {} } ); $constraint_ref = Data::Validation::Constraints->new( %config ); $constraint_ref->validate_value( $value );
Tests a single data value for conformance with a constraint
Uses the Moo::Role Data::Validation::Utils. Defines the following attributes:
A string containing the error message that is thrown if the validation fails
Used by "isValidLength". The length of the supplied value must be numerically less than this
Used by "isBetweenValues".
Used by "isValidLength".
If true then null values are not allowed regardless of what other validation would be done
Used by the "isEqualTo" method as the other value in the comparison
Called by Data::Validation::check_field this method implements tests for a null input value so that individual validation methods don't have to. It calls either a built in validation method or "_validate" which should have been overridden in a factory subclass. An exception is thrown if the data value is not acceptable
Should have been overridden in an external constraint subclass
Test to see if the supplied value is numerically greater than $self->min_value and less than $self->max_value
$self->min_value
$self->max_value
Test to see if the supplied value is equal to $self->value. Calls isValidNumber on both values to determine the type of comparison to perform
$self->value
isValidNumber
Tests to see if the value matches the regular expression for a hexadecimal number
Null values are not allowed
Does the supplied value match $self->pattern?
$self->pattern
Is the supplied value entirely composed of printable characters?
Simple text is defined as matching the pattern '\A [a-zA-Z0-9_ \-\.]+ \z'
Calls gethostbyname on the supplied value
gethostbyname
Identifiers must match the pattern '\A [a-zA-Z_] \w* \z'
Tests to see if the supplied value is an integer
Tests to see if the length of the supplied value is greater than $self->min_length and less than $self->max_length
$self->min_length
$self->max_length
Return true if the supplied value looks_like_number
looks_like_number
Each of these constraint subclasses implements the required _validate method
_validate
If the str2time method in the CatalystX::Usul::Class::Time module can parse the supplied value then it is deemed to be a valid date
str2time
If the address method in the Email::Valid module can parse the supplied value then it is deemed to be a valid email address
address
Currently implements a minimum password length of six characters and that the password contain at least one non alphabetic character
Screen out these characters: ; & * { } and space
Tests to see if the supplied value matches one of the approved patterns for a valid postcode
Call the request method in LWP::UserAgent to test if a URL is accessible
request
None
There are no known incompatibilities in this module
There is no POD coverage test because the subclasses docs are in here instead
The Data::Validation::Constraints::Date module requires the module CatalystX::Usul::Time and this is not listed as prerequisite as it would create a circular dependency
Please report problems to the address below. Patches are welcome
Peter Flanigan, <pjfl@cpan.org>
<pjfl@cpan.org>
Copyright (c) 2013 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
To install Data::Validation, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Validation
CPAN shell
perl -MCPAN -e shell install Data::Validation
For more information on module installation, please visit the detailed CPAN module installation guide.