« blib/lib/auto/share/dist/Cmd-Dwarf/app/lib/Dwarf/Util/Geo.pm
↑ Summary
blib/lib/auto/share/dist/Cmd-Dwarf/app/lib/Dwarf/Validator/NullValue.pm »
| 1 | package Dwarf::Validator::Constraint; | ||
| 2 | use Dwarf::Pragma; | ||
| 3 | #use Dwarf::Validator; | ||
| 4 | |||
| 5 | sub import { | ||
| 6 | strict->import; | ||
| 7 | warnings->import; | ||
| 8 | |||
| 9 | no strict 'refs'; | ||
| 10 | my $pkg = caller(0); | ||
| 11 | *{"$pkg\::rule"} = \&rule; | ||
| 12 | *{"$pkg\::file_rule"} = \&file_rule; | ||
| 13 | *{"$pkg\::filter"} = \&filter; | ||
| 14 | *{"$pkg\::alias"} = \&alias; | ||
| 15 | *{"$pkg\::delsp"} = \&delsp; | ||
| 16 | } | ||
| 17 | |||
| 18 | sub rule { | ||
| 19 | my ($name, $code) = @_; | ||
| 20 | $Dwarf::Validator::Rules->{$name} = $code; | ||
| 21 | } | ||
| 22 | |||
| 23 | sub file_rule { | ||
| 24 | my ($name, $code) = @_; | ||
| 25 | $Dwarf::Validator::FileRules->{$name} = $code; | ||
| 26 | } | ||
| 27 | |||
| 28 | sub filter { | ||
| 29 | my ($name, $code) = @_; | ||
| 30 | $Dwarf::Validator::Filters->{$name} = $code; | ||
| 31 | $Dwarf::Validator::Rules->{$name} = sub { | ||
| 32 | my ($opts) = @_; | ||
| 33 | return $Dwarf::Validator::Rules->{FILTER}->($name, $opts); | ||
| 34 | }; | ||
| 35 | } | ||
| 36 | |||
| 37 | sub alias { | ||
| 38 | my ($from, $to) = @_; | ||
| 39 | $Dwarf::Validator::Rules->{$to} = $Dwarf::Validator::Rules->{$from}; | ||
| 40 | } | ||
| 41 | |||
| 42 | sub delsp { | ||
| 43 | my $x = $_; | ||
| 44 | $x =~ s/\s//g; | ||
| 45 | return $x; | ||
| 46 | } | ||
| 47 | |||
| 48 | 1; |