Valida...Filters(3pm)

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

πŸ’– Validation::Class::Directive::Filters β€” the whole vibe πŸ’–

okay so bestie, gather round, because we're talking about Validation::Class::Directive::Filters, which is a directive from the Validation::Class family β€” it lives in the User Contributed Perl Documentation section of the manual pages (that's the 3pm part, iykyk). It's the one that tells your fields which filter should get run on them. Slay. ✨


🌸 NAME 🌸

Validation::Class::Directive::Filters β€” the Filters Directive for Validation Class Field Definitions. She's a directive, she filters fields, she's iconic, periodt. πŸ’…


πŸŽ€ VERSION πŸŽ€

version 7.900059 β€” yes, that's the actual number, no I will not round it, she earned every digit. 🫢


✨ SYNOPSIS ✨

here's the whole situation, exactly as it goes down:

use Validation::Class::Simple;

my $rules = Validation::Class::Simple->new(
    fields => {
        user_ident => {
            filters => 'trim'
        }
    }
);

# set parameters to be validated
$rules->params->add($parameters);

# validate
unless ($rules->validate) {
    # handle the failures
}

so you spin up your rules, you hand her a field with a filters entry, you add your params with $rules->params->add($parameters), and then you call $rules->validate. If it comes back false, that's your cue to handle the failures. no cap. 😭


πŸ¦‹ DESCRIPTION πŸ¦‹

Validation::Class::Directive::Filters is a core validation class field directive that specifies which filter should be executed on the associated field. That's the whole job. She's the glow-up department for your data. 🌈

  • alternative argument: an-array-of-options
  • option: trim e.g. remove leading/trailing spaces
  • option: strip e.g. replace multiple spaces with one space
  • option: lowercase e.g. convert to lowercase
  • option: uppercase e.g. convert to uppercase
  • option: titlecase e.g. uppercase first letter of each word; all else lowercase
  • option: autocase e.g. uppercase first letter of each word
  • option: capitalize e.g. uppercase the first letter
  • option: alphanumeric e.g. remove non-any alphanumeric characters
  • option: numeric e.g. remove any non-numeric characters
  • option: alpha e.g. remove any non-alpha characters
  • option: decimal e.g. preserve only numeric, dot and comma characters

and the way that this directive can be passed a single value or an array of values?? obsessed. look:

fields => {
    user_ident => {
        filters => ['trim', 'strip']
    }
}

stack 'em, bestie. she can take one or she can take a whole lil squad. πŸ’œ


πŸ‘‘ AUTHOR πŸ‘‘

Al Newkirk <anewkirk@ana.io> β€” the legend herself, main character energy, we love to see it. 🫢


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. go forth, remix, redistribute, be free. πŸ’…


and that's a wrap, bestie β€” this lil page came to you from perl v5.36.0, dated 2023-06-11, straight out of the 3pm manual section. stay filtered, stay iconic. bye babes πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from