diff options
author | Yorhel <git@yorhel.nl> | 2020-11-11 19:51:56 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-11-15 08:54:51 +0100 |
commit | 86af5725b6c6dc749c88e6cbc8ffcadf3bd97af6 (patch) | |
tree | 1533b02cf74088f4da6f7680be630f587baccdce /lib/VNWeb/Validation.pm | |
parent | 20011cf2f110d1d89d243ce77b122675463d93b5 (diff) |
Advsearch: Add release date filter
This required some changes to the query model and encoded form, since it
doing this with only <= and => operators is too limited.
I changed the compact encoding of strings to only encode the length in
the type field for specific (common) lengths and fallback to an
end-of-string character for everything else. This leaves room for more
custom types.
Diffstat (limited to 'lib/VNWeb/Validation.pm')
-rw-r--r-- | lib/VNWeb/Validation.pm | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/VNWeb/Validation.pm b/lib/VNWeb/Validation.pm index 50abda6c..f1a5d660 100644 --- a/lib/VNWeb/Validation.pm +++ b/lib/VNWeb/Validation.pm @@ -40,6 +40,7 @@ TUWF::set custom_validations => { language => { enum => \%LANGUAGE }, gtin => { required => 0, default => 0, func => sub { $_[0] = 0 if !length $_[0]; $_[0] eq 0 || gtintype($_[0]) } }, rdate => { uint => 1, func => \&_validate_rdate }, + fuzzyrdate => { func => \&_validate_fuzzyrdate }, # A tri-state bool, returns undef if not present or empty, normalizes to 0/1 otherwise undefbool => { required => 0, default => undef, func => sub { $_[0] = $_[0] ? 1 : 0; 1 } }, # An array that may be either missing (returns undef), a single scalar (returns single-element array) or a proper array @@ -78,6 +79,15 @@ sub _validate_rdate { } +sub _validate_fuzzyrdate { + $_[0] = 0 if $_[0] =~ /^unknown$/; + $_[0] = 1 if $_[0] =~ /^today$/; + $_[0] = 99999999 if $_[0] =~ /^tba$/; + return 1 if $_[0] eq 1; + VNWeb::Validation::_validate_rdate($_[0]); +} + + sub is_insecurepass { config->{password_db} && PWLookup::lookup(config->{password_db}, shift) } |