diff options
author | Yorhel <git@yorhel.nl> | 2020-04-06 17:01:14 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-04-06 17:01:17 +0200 |
commit | 91c5ca72e9c90c5a60f71e53a68c980094a59da8 (patch) | |
tree | 18fd78ab58ae08440ed9e2f70335851c51093a9e /lib/VNWeb/Validation.pm | |
parent | 6b04feb79ced4571150a64c19fd70539aa4596fb (diff) |
Release::Edit: Consider GTIN code as a string for validation/editing
Problem is that the 'uint' validation does not allow leading zeros,
which are very valid as part of GTIN codes, thus resulting in an error
when validating a normalized GTIN code.
Diffstat (limited to 'lib/VNWeb/Validation.pm')
-rw-r--r-- | lib/VNWeb/Validation.pm | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/VNWeb/Validation.pm b/lib/VNWeb/Validation.pm index f4508d6c..3467c013 100644 --- a/lib/VNWeb/Validation.pm +++ b/lib/VNWeb/Validation.pm @@ -30,7 +30,7 @@ TUWF::set custom_validations => { username => { regex => qr/^(?!-*[a-z][0-9]+-*$)[a-z0-9-]*$/, minlength => 2, maxlength => 15 }, password => { length => [ 4, 500 ] }, language => { enum => \%LANGUAGE }, - gtin => { uint => 1, func => sub { $_[0] eq 0 || gtintype($_[0]) } }, + gtin => { func => sub { $_[0] = 0 if !length $_[0]; $_[0] eq 0 || gtintype($_[0]) } }, rdate => { uint => 1, func => \&_validate_rdate }, # Accepts a user-entered vote string (or '-' or empty) and converts that into a DB vote number (or undef) - opposite of fmtvote() vnvote => { required => 0, default => undef, regex => qr/^(?:|-|[1-9]|10|[1-9]\.[0-9]|10\.0)$/, func => sub { $_[0] = $_[0] eq '-' ? undef : 10*$_[0]; 1 } }, |