From 475181f3ea5e4525c76d84303d66de99eafbfccb Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 9 Oct 2012 23:19:32 -0500 Subject: docs --- lib/MooseX/Meta/TypeConstraint/Doctype.pm | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'lib/MooseX/Meta') 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 function in L. It is a subclass of +L which adds a required C 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', -- cgit v1.2.3-54-g00ecf