| 1 | package Valiant::Filter::Upper; | ||
| 2 | |||
| 3 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Valiant::Util 'throw_exception'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | with 'Valiant::Filter::Each'; | |
| 7 | |||
| 8 | sub normalize_shortcut { | ||
| 9 | 1 | ▶ | my ($class, $arg) = @_; |
|
Subroutine
normalize_shortcut: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 10 | 1 | return +{ }; | |
| 11 | } | ||
| 12 | |||
| 13 | sub filter_each { | ||
| 14 | 1 | ▶ | my ($self, $class, $attrs, $attribute_name) = @_; |
|
Subroutine
filter_each: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 15 | 1 | my $value = $attrs->{$attribute_name}; | |
| 16 | 1 | return uc $value; | |
| 17 | } | ||
| 18 | |||
| 19 | 1 | 1; | |
| 20 | |||
| 21 | =head1 NAME | ||
| 22 | |||
| 23 | Valiant::Filter::Upper - up case a string | ||
| 24 | |||
| 25 | =head1 SYNOPSIS | ||
| 26 | |||
| 27 | package Local::Test::User; | ||
| 28 | |||
| 29 | use Moo; | ||
| 30 | use Valiant::Filters; | ||
| 31 | |||
| 32 | has 'name' => (is=>'ro', required=>1); | ||
| 33 | |||
| 34 | filters name => ( | ||
| 35 | upper => 1, | ||
| 36 | ); | ||
| 37 | |||
| 38 | my $user = Local::Test::User->new(name=>'john'); | ||
| 39 | |||
| 40 | print $user->name; # 'JOHN' | ||
| 41 | |||
| 42 | =head1 DESCRIPTION | ||
| 43 | |||
| 44 | This is a very simple filter that takes no paramters and just does a 'uc' on the | ||
| 45 | value of the attribute. | ||
| 46 | |||
| 47 | =head1 SEE ALSO | ||
| 48 | |||
| 49 | L<Valiant>, L<Valiant::Filter>, L<Valiant::Validator::Filter>. | ||
| 50 | |||
| 51 | =head1 AUTHOR | ||
| 52 | |||
| 53 | See L<Valiant> | ||
| 54 | |||
| 55 | =head1 COPYRIGHT & LICENSE | ||
| 56 | |||
| 57 | See L<Valiant> | ||
| 58 | |||
| 59 | =cut | ||