| 1 | package Badger::Data::Facet::Number; | ||
| 2 | |||
| 3 | use Badger::Class | ||
| 4 | version => 0.01, | ||
| 5 | base => 'Badger::Data::Facet', | ||
| 6 | utils => 'numlike', | ||
| 7 | messages => { | ||
| 8 | not_number => '%s is not a number (got %s)', | ||
| 9 | too_small => '%s should be no less than %d (got %d)', | ||
| 10 | too_large => '%s should be no more than %d (got %d)', | ||
| 11 | }; | ||
| 12 | |||
| 13 | |||
| 14 | sub validate { | ||
| 15 | my ($self, $value, $type) = @_; | ||
| 16 | |||
| 17 | return numlike $$value | ||
| 18 | || $self->invalid_msg( not_number => $type || 'Text', $$value ); | ||
| 19 | } | ||
| 20 | |||
| 21 | |||
| 22 | 1; | ||
| 23 | |||
| 24 | __END__ |