diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-09 23:19:32 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-10-09 23:19:32 -0500 |
commit | 475181f3ea5e4525c76d84303d66de99eafbfccb (patch) | |
tree | d55bc7773aefb97b30555b1db8fdc9bff5d36b04 /lib/MooseX/Meta | |
parent | bb2bf61723962222952d2f68da497f8391dc6a5e (diff) | |
download | moosex-validation-doctypes-475181f3ea5e4525c76d84303d66de99eafbfccb.tar.gz moosex-validation-doctypes-475181f3ea5e4525c76d84303d66de99eafbfccb.zip |
docs
Diffstat (limited to 'lib/MooseX/Meta')
-rw-r--r-- | lib/MooseX/Meta/TypeConstraint/Doctype.pm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/MooseX/Meta/TypeConstraint/Doctype.pm b/lib/MooseX/Meta/TypeConstraint/Doctype.pm index 0d333cc..9502424 100644 --- a/lib/MooseX/Meta/TypeConstraint/Doctype.pm +++ b/lib/MooseX/Meta/TypeConstraint/Doctype.pm @@ -1,5 +1,6 @@ package MooseX::Meta::TypeConstraint::Doctype; use Moose; +# ABSTRACT: Moose type constraint for validating doctypes use Devel::PartialDump 'dump'; use Moose::Util::TypeConstraints qw(class_type find_type_constraint @@ -8,10 +9,45 @@ use Scalar::Util 'weaken'; use MooseX::Validation::Doctypes::Errors; +=head1 SYNOPSIS + + use MooseX::Validation::Doctypes; + + doctype 'Person' => { + id => 'Str', + name => 'Str', + title => 'Str', + }; + + use JSON; + + my $data = decode_json('{"id": "1234-A", "name": "Bob", "title": "CIO"}'); + + use Moose::Util::TypeConstraints; + + my $person = find_type_constraint('Person'); + die "Data is invalid" unless $person->check($data); + +=head1 DESCRIPTION + +This module implements the actual type constraint that is created by the +C<doctype> function in L<MooseX::Validation::Doctypes>. It is a subclass of +L<Moose::Meta::TypeConstraint> which adds a required C<doctype> parameter, and +automatically generates a constraint and message which validate based on that +doctype (as described in the MooseX::Validation::Doctypes docs). + +=cut + extends 'Moose::Meta::TypeConstraint'; class_type('Moose::Meta::TypeConstraint'); +=attr doctype + +The doctype to validate. Required. + +=cut + has doctype => ( is => 'ro', isa => 'Ref', |