NAME

Valiant::Filter::Numberize - Force into number context

SYNOPSIS

  package Local::Test::User;

  use Moo;
  use Valiant::Filters;

  has 'age' => (is=>'ro', required=>1);

  filters age => (
    numberize => 1,
  );

  my $user = Local::Test::User->new(age=>'25');
  print $user->age; # 25

  my $not_a_number = Local::Test::User(age=>'aaaabbbccc');
  print $not_a_number; # 0

  

DESCRIPTION

This is a very simple filter that takes no paramters and just forces a value into number context. Please note that this mean strings with letters and other non number values will almost always end up as 0 without returning any validation errors. If you want to notice and handle this as a validation then you might want to check Valiant::Validator::Numericality instead,

SEE ALSO

Valiant, Valiant::Filter, Valiant::Validator::Filter.

AUTHOR

See Valiant

COPYRIGHT & LICENSE

See Valiant