summaryrefslogtreecommitdiffstats
path: root/lib/MooseX/Validation/Doctypes.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MooseX/Validation/Doctypes.pm')
-rw-r--r--lib/MooseX/Validation/Doctypes.pm35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/MooseX/Validation/Doctypes.pm b/lib/MooseX/Validation/Doctypes.pm
index e69de29..668c4f0 100644
--- a/lib/MooseX/Validation/Doctypes.pm
+++ b/lib/MooseX/Validation/Doctypes.pm
@@ -0,0 +1,35 @@
+package MooseX::Validation::Doctypes;
+use strict;
+use warnings;
+
+use MooseX::Meta::TypeConstraint::Doctype;
+
+use Sub::Exporter -setup => {
+ exports => ['doctype'],
+ groups => {
+ default => ['doctype'],
+ },
+};
+
+sub doctype {
+ my $name;
+ $name = shift if @_ > 1;
+
+ my ($doctype) = @_;
+
+ # XXX validate name
+
+ my $args = {
+ ($name ? (name => $name) : ()),
+ doctype => $doctype,
+ package_defined_in => scalar(caller),
+ };
+
+ my $tc = MooseX::Meta::TypeConstraint::Doctype->new($args);
+ Moose::Util::TypeConstraints::register_type_constraint($tc)
+ if $name;
+
+ return $tc;
+}
+
+1;