| Form-Factory documentation | Contained in the Form-Factory distribution. |
Form::Factory::Feature::Control::Trim - Trims whitespace from a control value
version 0.020
has_control title => (
control => 'text',
features => {
trim => 1,
},
);
Strips whitespace from the front and back of the given values.
Reports an error unless the control is a scalar value.
Strips whitespace from the start and end of the control value.
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
Copyright 2009 Qubling Software LLC.
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.
| Form-Factory documentation | Contained in the Form-Factory distribution. |
package Form::Factory::Feature::Control::Trim; BEGIN { $Form::Factory::Feature::Control::Trim::VERSION = '0.020'; } use Moose; with qw( Form::Factory::Feature Form::Factory::Feature::Role::Clean Form::Factory::Feature::Role::Control ); use Carp ();
sub check_control { my ($self, $control) = @_; return if $control->does('Form::Factory::Control::Role::ScalarValue'); Carp::croak("the trim feature only works on scalar values, not $control"); }
sub clean { my $self = shift; my $control = $self->control; my $value = $control->current_value; $value =~ s/^\s*//; $value =~ s/\s*$//; $control->current_value($value); }
1;