View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Paul Golds > Tie-Assert-0.12 > Tie::Assert::CheckFactory



Annotate this POD


Open  0
View/Report Bugs
Module Version: 0.12   Source  


Tie::Assert::CheckFactory - Creates checks for Tie::Assert


This document refers to version 0.12 of Tie::Assert::CheckFactory, released Oct 13th 2004.


  # Create a $age variable which needs to be in the range of
  #  zero to a hundred and twenty.
  my $age;
  tie ($age, 'Tie::Assert::Scalar',

  # Perfectly fine..
  $age = 23;

  # ..causes fatal error.
  $age = 1723;


This module contains prebuilt useful checks for the Tie::Assert module, to use the checks simply include them when you tie() a variable to Tie::Assert::Scalar (..or it's relatives), or pass them in with the add_check() method.

See the documentation for Tie::Assert for more information.


Tie::Assert::CheckFactory methods can be called in either OO or procedural style, it makes no difference. The following two code fragments are effectively identical:

  my $factory = Tie::Assert::CheckFactory->new();


If you choose to use the OO-style calls the constructor takes no parameters.


As mentioned under 'CONSTRUCTOR AND INITIALISATION' above, the following can be called either procedurally or in an object-oriented style as you see fit.

array_ref ()

The variable must contain an array reference.

can (@methods)

The variable must contain an object reference which supports the listed @methods.

code_ref ()

The variable must contain a code reference.

glob_ref ()

The variable must contain a glob reference. (Currently untested)

hash_ref ()

The variable must contain a hash reference.

integer_ok ()

The variable must be an integer.

isa ($class)

The variable must contain an object reference which must either be of type $class, or a descendant.

lvalue_ref ()

The variable must contain an lvalue reference. (Currently untested)

min ($min)

The variable cannot be lower than $min.

max ($max)

The variable cannot be larger than $max.

number_ok ()

The variable must have a numeric value.

range ($min, $max)

The variable must be in the range $min-$max, inclusive.

ref_to ($type_name)

The variable must contain a reference to the supplied typename, often the name of a class the variable is to store.

Note that the standard array, code, glob, hash, lvalue, and scalar types are already covered by other methods provided by this class, such as array_ref, but you can call this yourself if you wish.

regex (qr/regex/i)

The variable must match the regular expression provided.

scalar_ref ()

The variable must be a reference to a scalar.

string_ok ()

The variable must remain a valid string, it won't be stringified in order to comply.


No known bugs.


This module is ALPHA code, it's seemed stable in a number of projects but the interface is liable to change before the final release.


Tie::Aspect, Tie::Aspect::Scalar


Paul Golds (


Copyright (c) 2004, Paul Golds. All rights reserved. This module is free software. It may be used, redistributed, and/or modified under the same terms as Perl itself.

syntax highlighting: