summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-04-06 20:36:59 +0200
committerYorhel <git@yorhel.nl>2020-04-06 20:36:59 +0200
commite4846f1b328c5a53e38dc9258f8c02ec31b58e1d (patch)
treec9dd0c32766ee928719c8fffaf0654bd6caff656
parent7cfc606c4ae05814fb4dde6fce90dcb09cb93679 (diff)
Releases::Edit: Fixup: Allow empty GTIN field
-rw-r--r--elm/ReleaseEdit.elm2
-rw-r--r--lib/VNWeb/Validation.pm2
2 files changed, 2 insertions, 2 deletions
diff --git a/elm/ReleaseEdit.elm b/elm/ReleaseEdit.elm
index 275052d8..0ec3fe34 100644
--- a/elm/ReleaseEdit.elm
+++ b/elm/ReleaseEdit.elm
@@ -92,7 +92,7 @@ init d =
, plat = Set.fromList <| List.map (\e -> e.platform) d.platforms
, platDd = DD.init "platforms" PlatOpen
, media = List.map (\m -> { m | qty = if m.qty == 0 then 1 else m.qty }) d.media
- , gtin = String.padLeft 12 '0' d.gtin
+ , gtin = if d.gtin == "0" then "" else String.padLeft 12 '0' d.gtin
, gtinValid = True
, catalog = d.catalog
, released = d.released
diff --git a/lib/VNWeb/Validation.pm b/lib/VNWeb/Validation.pm
index 3467c013..8786e47b 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 => { func => sub { $_[0] = 0 if !length $_[0]; $_[0] eq 0 || gtintype($_[0]) } },
+ gtin => { required => 0, default => 0, 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 } },