| 1 | |||
| 2 | package XML::EPP::Common; | ||
| 3 | |||
| 4 | 2 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 0 | ▶ | use MooseX::Method::Signatures; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 6 | |||
| 7 | # this file does not implement a document format or a node, so it | ||
| 8 | # doesn't consume the XML::EPP role. | ||
| 9 | |||
| 10 | use constant XSI_XMLNS => "http://www.w3.org/2001/XMLSchema-instance"; | ||
| 11 | |||
| 12 | use Moose::Util::TypeConstraints; | ||
| 13 | |||
| 14 | our $PKG; | ||
| 15 | BEGIN { | ||
| 16 | $PKG = "XML::EPP::Common"; | ||
| 17 | } | ||
| 18 | |||
| 19 | #===================================================================== | ||
| 20 | # eppcom-1.0.xsd mapping to types | ||
| 21 | #===================================================================== | ||
| 22 | # see EPP.pm, nearby, for introdutory explanatory notes | ||
| 23 | |||
| 24 | # this is a custom mapping. Probably many of them will be for this | ||
| 25 | # class, as our normal definition of what to call the classes - based | ||
| 26 | # on the element name in which they are used - falls down completely; | ||
| 27 | # this spec for the most part defines types for use by the other | ||
| 28 | # standards. | ||
| 29 | |||
| 30 | use PRANG::XMLSchema::Types; | ||
| 31 | BEGIN{ | ||
| 32 | subtype "${PKG}::reasonBaseType" | ||
| 33 | => as "PRANG::XMLSchema::token" | ||
| 34 | => where { | ||
| 35 | length($_) >= 1 and length($_) <= 32; | ||
| 36 | }; | ||
| 37 | |||
| 38 | subtype "${PKG}::clIDType" | ||
| 39 | => as "PRANG::XMLSchema::token" | ||
| 40 | => where { | ||
| 41 | length($_) >= 3 and length($_) <= 16; | ||
| 42 | }; | ||
| 43 | subtype "${PKG}::labelType" | ||
| 44 | => as "PRANG::XMLSchema::token" | ||
| 45 | => where { | ||
| 46 | length($_) >= 1 and length($_) <= 255; | ||
| 47 | }; | ||
| 48 | |||
| 49 | subtype "${PKG}::minTokenType" | ||
| 50 | => as "PRANG::XMLSchema::token" | ||
| 51 | => where { | ||
| 52 | length($_) >= 1; | ||
| 53 | }; | ||
| 54 | |||
| 55 | subtype "${PKG}::roidType" | ||
| 56 | => as "PRANG::XMLSchema::token" | ||
| 57 | => where { | ||
| 58 | m{^(?:[^\p{P}\p{Z}\p{C}]|_){1,80}-[^\p{P}\p{Z}\p{C}]{1,8}}; | ||
| 59 | }; | ||
| 60 | |||
| 61 | # XXX: | ||
| 62 | # this doesn't work when I use it in XML::EPP::Domain::Tranfer::Response | ||
| 63 | # Enum seems to work for attrs (see above) but not for elements. | ||
| 64 | #enum "${PKG}::trStatusType" => | ||
| 65 | # qw(clientApproved clientCancelled clientRejected pending | ||
| 66 | # serverApproved serverCancelled); | ||
| 67 | |||
| 68 | # but this _does_ work when I use it in XML::EPP::Domain::Tranfer::Response | ||
| 69 | subtype "${PKG}::trStatusType" | ||
| 70 | => as 'Str' | ||
| 71 | => where { | ||
| 72 | m{^clientApproved|clientCancelled|clientRejected|pending|serverApproved|serverCancelled$}; | ||
| 73 | }; | ||
| 74 | } | ||
| 75 | |||
| 76 | # allow any dateTime field to automatically coerce from timestamptz's | ||
| 77 | use MooseX::TimestampTZ; | ||
| 78 | coerce "PRANG::XMLSchema::dateTime" | ||
| 79 | => from "TimestampTZ" | ||
| 80 | => via { | ||
| 81 | my $x = $_; | ||
| 82 | $x =~ s{ }{T}; | ||
| 83 | $x =~ s{([+\-]\d{2})(\d{2})}{$1:$2}; | ||
| 84 | $x; | ||
| 85 | }; | ||
| 86 | |||
| 87 | use XML::EPP::Common::Reason; | ||
| 88 | |||
| 89 | # "AuthInfo" is usually introduced with a <pw> tag, so we'll call it | ||
| 90 | # Password | ||
| 91 | use XML::EPP::Common::Password; | ||
| 92 | |||
| 93 | # <ext>, but it's basically still a password. | ||
| 94 | use XML::EPP::Common::ExtPassword; | ||
| 95 | |||
| 96 | use XML::EPP::Common::Reason; | ||
| 97 | |||
| 98 | 1; | ||
| 99 | |||
| 100 | =head1 NAME | ||
| 101 | |||
| 102 | XML::EPP::Common | ||
| 103 | |||
| 104 | =head2 SYNOPSIS | ||
| 105 | |||
| 106 | ... | ||
| 107 | |||
| 108 | =head2 DESCRIPTION | ||
| 109 | |||
| 110 | ... | ||
| 111 | |||
| 112 | =cut | ||