The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::Sah::Type::Sortable - Specification for sortable types

VERSION

version 0.02

DESCRIPTION

This is the Sortable role. It provides clauses like 'lt' ("less than"), 'gt' ("greater than"), and so on. It is used by many types, for example 'str', all numeric types, etc.

Role consumer must provide method 'superclause_sortable' which will receive the same %args as clause methods, but with additional key: -which (either 'min', 'max', 'xmin', 'xmax').

CLAUSES

Unless specified otherwise, all clauses have a priority of 50 (normal).

min => VALUE

Require that the value is not less than some specified minimum (equivalent in intention to the Perl string 'ge' operator, or the numeric >= operator).

Example:

 [int => {min => 0}] # specify positive numbers

xmin => VALUE

Require that the value is not less nor equal than some specified minimum (equivalent in intention to the Perl string 'gt' operator, or the numeric > operator). The "x" prefix is for "exclusive".

max => VALUE

Require that the value is less or equal than some specified maximum (equivalent in intention to the Perl string 'le' operator, or the numeric <= operator).

xmax => VALUE

Require that the value is less than some specified maximum (equivalent in intention to the Perl string 'lt' operator, or the numeric < operator). The "x" prefix is for "exclusive".

between => [MIN, MAX]

A convenient clause to combine min and max.

Example, the following schemas are equivalent:

 [float => {between => [0.0, 1.5]}]
 [float => {min => 0.0, max => 1.5}]

xbetween => [MIN, MAX]

A convenient clause to combine xmin and xmax.

AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Steven Haryanto.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.