File: 98-anomaly.t

package info (click to toggle)
libvalidation-class-perl 7.900057-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,572 kB
  • ctags: 355
  • sloc: perl: 21,493; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 693 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use Test::More tests => 2;

package MyVal;
use Validation::Class;

package main;

my $params = {_dc => '0123456789'};

my $v = MyVal->new(
    fields => {
        status => {
            required => 1,
            error    => 'Invalid account status. Use Active/Inactive.',
            filters  => ['trim', 'strip', 'alpha'],
            options  => 'Active, Inactive'
        }
    },
    params         => {_dc => '0123456789'},
    ignore_unknown => 1
);

# params set at new function
ok $v->validate(keys %{$params}), 'validation ok';

# ok $v->fields->{_dc}, 'found anomaly, param converted to field';
ok !$v->fields->{_dc},
  'anomaly fixed, unknown param no longer converted to field';