Valida...Decimal(3pm)
π¦ Validation::Class::Directive::Decimal β the Decimal Directive for Validation Class Field Definitions π
okay bestie, so this is a page from the User Contributed Perl Documentation, and it's literally all about one little directive that does one little job and does it flawlessly. it's giving "small but mighty." we love a specialist. π
β¨ VERSION β¨
version 7.900059 β yes that's the whole number, no I will not round it, it's iconic.
πΈ SYNOPSIS πΈ
here's the vibe, copy-paste ready, no cap:
use Validation::Class::Simple;
my $rules = Validation::Class::Simple->new(
fields => {
amount_paid => {
decimal => 1
}
}
);
# set parameters to be validated
$rules->params->add($parameters);
# validate
unless ($rules->validate) {
# handle the failures
}
so you set up your $rules, you drop your $parameters in, you validate, and if it comes back false you deal with the failures. that's the whole loop. periodt. π
π DESCRIPTION π
Validation::Class::Directive::Decimal is a core validation class field directive that provides validation of floating point integers. that's its whole personality and honestly? slay.
- alternative argument: a-single-variable-value β so like, one value. one. not a list, not a crowd. a single value. π
- option:
0e.g. Any number of decimal places, including none - option:
1e.g. Any number of decimal places greater than 0, or afloat|double - option:
$ne.g. Exactly that many number of decimal places
bestie heads up: This directive can be passed a single value only β that's not a suggestion, that's the rule. π
and here's how that looks when you're being precise about it:
fields => {
amount_paid => {
decimal => 2 # 2 decimal places
}
}
see how decimal => 2 is just one value? yeah. that. exactly that many decimal places, bestie. 0 is "any number, even zero, go off," 1 is "any number greater than 0, or a float/double," and $n is "exactly n, no more, no less, we're strict in this house." π₯
π AUTHOR π
Al Newkirk <anewkirk@ana.io> β the mastermind. the main character. we stan. π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2011 by Al Newkirk.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. (yes, the actual Perl 5 language system. legal said so. π«Ά)
and that's the whole page, bestie!! this lil manpage came to you from the User Contributed Perl Documentation, version 7.900059, riding on perl v5.36.0, dated 2023-06-11. you're so welcome. go validate some floats. πβ¨
π¦ where this page comes from
- debian trixie: libvalidation-class-perl 7.900059-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libvalidation-class-perl 7.900059-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libvalidation-class-perl 7.900059-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libvalidation-class-perl 7.900059-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms