summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2015-09-20 15:12:05 +0200
committerYorhel <git@yorhel.nl>2015-09-20 15:12:05 +0200
commitbb7a7cc178144457d401c3c6479a41788cf681dd (patch)
tree40bd705081da74c2e665d0c7552dad2c34bcb43c /lib
parent28681f6b12b1d8958ae1d792bb831120530de15a (diff)
formValidate: Created templates for gtin and editsum fields
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/Handler/Chars.pm3
-rw-r--r--lib/VNDB/Handler/Producers.pm3
-rw-r--r--lib/VNDB/Handler/Releases.pm6
-rw-r--r--lib/VNDB/Handler/Staff.pm3
-rw-r--r--lib/VNDB/Handler/VNEdit.pm3
-rw-r--r--lib/VNDB/Util/FormHTML.pm9
6 files changed, 13 insertions, 14 deletions
diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm
index b02bce5c..7171d506 100644
--- a/lib/VNDB/Handler/Chars.pm
+++ b/lib/VNDB/Handler/Chars.pm
@@ -302,11 +302,10 @@ sub edit {
{ post => 'main_spoil', required => 0, default => 0, enum => [ 0..2 ] },
{ post => 'traits', required => 0, default => '', regex => [ qr/^(?:[1-9]\d*-[0-2])(?: +[1-9]\d*-[0-2])*$/, 'Incorrect trait format.' ] },
{ post => 'vns', required => 0, default => '', regex => [ qr/^(?:[1-9]\d*-\d+-[0-2]-[a-z]+)(?: +[1-9]\d*-\d+-[0-2]-[a-z]+)*$/, 'Incorrect VN format.' ] },
- { post => 'editsum', required => 0, maxlength => 5000 },
+ { post => 'editsum', template => 'editsum' },
{ post => 'ihid', required => 0 },
{ post => 'ilock', required => 0 },
);
- push @{$frm->{_err}}, 'badeditsum' if !$frm->{editsum} || lc($frm->{editsum}) eq lc($frm->{desc});
# handle image upload
$frm->{image} = _uploadimage($self, $frm);
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index 8314af48..6369d4d1 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -226,11 +226,10 @@ sub edit {
{ post => 'l_wp', required => 0, maxlength => 150, default => '' },
{ post => 'desc', required => 0, maxlength => 5000, default => '' },
{ post => 'prodrelations', required => 0, maxlength => 5000, default => '' },
- { post => 'editsum', required => 0, maxlength => 5000 },
+ { post => 'editsum', template => 'editsum' },
{ post => 'ihid', required => 0 },
{ post => 'ilock', required => 0 },
);
- push @{$frm->{_err}}, 'badeditsum' if !$frm->{editsum} || lc($frm->{editsum}) eq lc($frm->{desc});
if(!$frm->{_err}) {
# parse
my $relations = [ map { /^([a-z]+),([0-9]+),(.+)$/ && (!$pid || $2 != $pid) ? [ $1, $2, $3 ] : () } split /\|\|\|/, $frm->{prodrelations} ];
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index 4c4e7d54..b06a62f3 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -304,8 +304,7 @@ sub edit {
{ post => 'doujin', required => 0, default => 0 },
{ post => 'title', maxlength => 250 },
{ post => 'original', required => 0, default => '', maxlength => 250 },
- { post => 'gtin', required => 0, default => '0',
- func => [ \&gtintype, 'Not a valid JAN/UPC/EAN code' ] },
+ { post => 'gtin', required => 0, default => '0', template => 'gtin' },
{ post => 'catalog', required => 0, default => '', maxlength => 50 },
{ post => 'languages', multi => 1, enum => $self->{languages} },
{ post => 'website', required => 0, default => '', maxlength => 250, template => 'weburl' },
@@ -320,12 +319,11 @@ sub edit {
{ post => 'ani_ero', required => 0, default => 0, enum => $self->{animated} },
{ post => 'producers', required => 0, default => '' },
{ post => 'vn', maxlength => 5000 },
- { post => 'editsum', required => 0, maxlength => 5000 },
+ { post => 'editsum', template => 'editsum' },
{ post => 'ihid', required => 0 },
{ post => 'ilock', required => 0 },
);
- push @{$frm->{_err}}, 'badeditsum' if !$frm->{editsum} || lc($frm->{editsum}) eq lc($frm->{notes});
push @{$frm->{_err}}, [ 'released', 'required', 1 ] if !$frm->{released};
my($media, $producers, $new_vn);
diff --git a/lib/VNDB/Handler/Staff.pm b/lib/VNDB/Handler/Staff.pm
index 75a1a97e..52b2e1f1 100644
--- a/lib/VNDB/Handler/Staff.pm
+++ b/lib/VNDB/Handler/Staff.pm
@@ -210,11 +210,10 @@ sub edit {
{ post => 'l_twitter', required => 0, maxlength => 16, default => '', regex => [ qr/^\S+$/, mt('_staffe_form_tw_err') ] },
{ post => 'l_anidb', required => 0, template => 'id', default => undef },
{ post => 'aliases', required => 0, maxlength => 5000, default => '' },
- { post => 'editsum', required => 0, maxlength => 5000 },
+ { post => 'editsum', template => 'editsum' },
{ post => 'ihid', required => 0 },
{ post => 'ilock', required => 0 },
);
- push @{$frm->{_err}}, 'badeditsum' if !$frm->{editsum} || lc($frm->{editsum}) eq lc($frm->{desc});
my $aliases = json_validate($frm, 'aliases',
{ field => 'name', required => 1, maxlength => 200 },
{ field => 'orig', required => 0, maxlength => 200, default => '' },
diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm
index 5757f830..409c80cb 100644
--- a/lib/VNDB/Handler/VNEdit.pm
+++ b/lib/VNDB/Handler/VNEdit.pm
@@ -121,11 +121,10 @@ sub edit {
{ post => 'seiyuu', required => 0, default => '[]', maxlength => 5000 },
{ post => 'vnrelations', required => 0, default => '', maxlength => 5000 },
{ post => 'screenshots', required => 0, default => '', maxlength => 1000 },
- { post => 'editsum', required => 0, maxlength => 5000 },
+ { post => 'editsum', required => !$nosubmit, template => 'editsum' },
{ post => 'ihid', required => 0 },
{ post => 'ilock', required => 0 },
);
- push @{$frm->{_err}}, 'badeditsum' if !$nosubmit && (!$frm->{editsum} || lc($frm->{editsum}) eq lc($frm->{desc}));
my $raw_c = !$frm->{_err} && json_validate($frm, 'credits',
{ field => 'aid', required => 1, template => 'id' },
{ field => 'role', required => 1, enum => $self->{staff_roles} },
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index b994792e..a319ba42 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -31,13 +31,18 @@ sub htmlFormError {
next;
}
my($field, $type, $rule) = @$e;
- li mt '_formerr_required', $field if $type eq 'required';
+ if($type eq 'required') {
+ li; lit mt $field eq 'editsum' ?'_formerr_tpl_editsum' : '_formerr_required', $field; end;
+ }
li mt '_formerr_minlength', $field, $rule if $type eq 'minlength';
li mt '_formerr_maxlength', $field, $rule if $type eq 'maxlength';
li mt '_formerr_enum', $field, join ', ', @$rule if $type eq 'enum';
li mt '_formerr_wrongboard', $rule if $type eq 'wrongboard';
li $rule->[1] if $type eq 'func' || $type eq 'regex';
- li mt "_formerr_tpl_$rule", $field if $type eq 'template';
+ if($type eq 'template') {
+ $rule = 'int' if $rule eq 'num' || $rule eq 'uint';
+ li; lit mt "_formerr_tpl_$rule", $field; end;
+ }
if($type eq 'tagexists') {
li; lit mt '_formerr_tagexists', "/g$rule->{id}", $rule->{name}; end;
}