Declar...erical(3pm)

πŸ“¦
version 0.03 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Declare::Constraints::Simple::Library::Numerical πŸ’–

okay bestie, so this is the Declare::Constraints::Simple::Library::Numerical page from the User Contributed Perl Documentation, and it is exactly what it says on the tin: a whole little library of constraints for checking that your values are, in fact, numbers. numbers only. no chaos. no sneaky strings pretending to be math. we're doing a vibe check on your scalars and we are NOT letting the impostors through. periodt. πŸ¦‹


✨ SYNOPSIS ✨

the receipts, fr fr β€” here's how you'd actually use these bad boys:

# test for number-conformity
my $looks_like_number = IsNumber;

# only integers
my $is_int = IsInt;

like. look at that. two whole lines. we love a low-effort, high-reward situation. πŸ’…


πŸŽ€ DESCRIPTIONS πŸŽ€

This library contains the constraints needed to validate numerical values.

that's the whole thing!! it's a little library that exists so you can validate numbers. it does one job and it does it flawlessly. main character energy honestly. πŸ‘‘


πŸ”₯ CONSTRAINTS πŸ”₯

IsNumber()

True if the value is a number according to Scalar::Utils looks_like_number.

so like β€” it's not just "is this digits", it's handing the question off to looks_like_number from Scalar::Utils, and if that says yes, this constraint says yes. it's giving "I trust the experts" and honestly? iconic of it. ✨

IsInt()

True if the value is an integer.

whole numbers only, bestie. 3? yes. 3.5? absolutely not, get out of here. πŸš«πŸ“


πŸ‘€ SEE ALSO πŸ‘€

go read these next, they're the whole friend group:

  • Declare::Constraints::Simple
  • Declare::Constraints::Simple::Library

πŸ’œ AUTHOR πŸ’œ

Robert 'phaylon' Sedlacek <phaylon@dunkelheit.at>

shoutout to phaylon, the original icon, the blueprint, the moment. 🫢


This module is free software, you can redistribute it and/or modify it under the same terms as perl itself.

so yes, you can remix it, redistribute it, do your little thing with it β€” just keep it under the same terms as perl itself. free software stays free software, no cap. πŸ’–

and that's the whole page!! this was perl v5.32.0, dated 2021-01-09, straight from the User Contributed Perl Documentation, and you have officially read the entirety of Declare::Constraints::Simple::Library::Numerical. go forth and validate those numbers. slay. πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from