| MooseX-Types-Locale-Country documentation | view source | Contained in the MooseX-Types-Locale-Country distribution. |
MooseX::Types::Locale::Country - Locale::Country related constraints and coercions for Moose
This document describes
MooseX::Types::Locale::Country
version 0.04.
{
package Foo;
use Moose;
use MooseX::Types::Locale::Country qw(
CountryCode
Alpha2Country
Alpha3Country
NumericCountry
CountryName
);
has 'code'
=> ( isa => CountryCode, is => 'rw', coerce => 1 );
has 'alpha2'
=> ( isa => Alpha2Country, is => 'rw', coerce => 1 );
has 'alpha3'
=> ( isa => Alpha3Country, is => 'rw', coerce => 1 );
has 'numeric'
=> ( isa => NumericCountry, is => 'rw' ); # you can't coerce
has 'name'
=> ( isa => CountryName, is => 'rw', coerce => 1 );
__PACKAGE__->meta->make_immutable;
}
my $foo = Foo->new(
code => 'jp',
alpha2 => 'jp',
alpha3 => 'jpn',
numeric => 392,
name => 'JAPAN',
);
print $foo->code; # 'JP'
print $foo->alpha2; # 'JP'
print $foo->alpha3; # 'JPN'
print $foo->numeric; # 392
print $foo->name; # 'Japan'
This module packages several Moose::Util::TypeConstraints with coercions, designed to work with the values of Locale::Country.
Alpha2CountryA subtype of Str, which should be defined in country code of ISO 3166-1
alpha-2.
If you turned coerce on, Str will be upper-case.
For example, 'jp' will convert to 'JP'.
CountryCodeAlias of Alpha2Country.
Alpha3CountryA subtype of Str, which should be defined in country code of ISO 3166-1
alpha-3.
If you turned coerce on, Str will be upper-case.
For example, 'jpn' will convert to 'JPN'.
NumericCountryA subtype of Int, which should be defined in country code of ISO 3166-1
numeric.
CountryNameA subtype of Str, which should be defined in ISO 3166-1 country name.
If you turned coerce on, Str will be same case as canonical name.
For example, 'JAPAN' will convert to 'Japan'.
These coercions is not support code conversion.
For example, from Alpha2Country to Alpha3Country.
has country
=> ( is => 'rw', isa => Alpha2Country, coerce => 1 );
...
$foo->country('US'); # does not convert to 'USA'
If you want conversion, could you implement an individual country class with several attributes?
See /examples/complex.pl in the distribution for more details.
This module provides you the optional type mapping of MooseX::Getopt when MooseX::Getopt was installed.
CountryCode, Alpha2Country, Alpha3Country and CountryName are
String ("=s") type.
NumericCountry is Int ("=i") type.
None reported.
CountryAsAlpha2 as existent Alpha2Country.'Locale::Country::Alpha2' as export typeAlpha2Country.No bugs have been reported.
Please report any found bugs, feature requests, and ideas for improvements
to bug-moosex-types-locale-country at rt.cpan.org,
or through the web interface
at http://rt.cpan.org/Public/Bug/Report.html?Queue=MooseX-Types-Locale-Country.
I will be notified, and then you'll automatically be notified of progress on your bugs/requests as I make changes.
When reporting bugs, if possible, please add as small a sample as you can make of the code that produces the bug. And of course, suggestions and patches are welcome.
You can find documentation for this module with the perldoc command.
perldoc MooseX::Types::Locale::Country
You can also look for information at:
http://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-Locale-Country
http://cpanratings.perl.org/dist/MooseX-Types-Locale-Country
This module is maintained using git. You can get the latest version from git://github.com/gardejo/p5-moosex-types-locale-country.git.
<moriya at cpan dot org>,
http://gardejo.org/
Copyright (c) 2009-2010 MORIYA Masaki, alias Gardejo
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlgpl (perlgpl) and perlartistic (perlartistic).
The full text of the license can be found in the LICENSE file included with this distribution.
| MooseX-Types-Locale-Country documentation | view source | Contained in the MooseX-Types-Locale-Country distribution. |