Valida...Decimal(3pm)

πŸ“¦
version 7.900059 Β· 7 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ¦‹ 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: 0 e.g. Any number of decimal places, including none
  • option: 1 e.g. Any number of decimal places greater than 0, or a float|double
  • option: $n e.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. πŸ’œ


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