
Data::Validation::Constraints - Test data values for conformance with constraints

0.4.$Revision: 114 $

use Data::Validation::Constraints;
%config = ( method => $method,
exception => q(Exception::Class),
%{ $self->constraints->{ $id } || {} } );
$constraint_ref = Data::Validation::Constraints->new( %config );
$constraint_ref->validate( $value );

Tests a single data value for conformance with a constraint

Uses the Data::Validation::Utils Moose::Role. 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".
Used by "isBetweenValues".
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
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
Null values are not allowed
Does the supplied value match $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
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
Return true if the supplied value looks_like_number

Each of these constraint subclasses implements the required _validate method
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
If the address method in the Email::Valid module can parse the supplied value then it is deemed to be a valid email 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

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 as yet unpublished module CatalystX::Usul::Class::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, <Support at RoxSoft.co.uk>

Copyright (c) 2008 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