aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Roles/ConfirmValidation.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2020-09-29 14:23:52 +0200
committerMarius Halden <marius.h@lden.org>2020-09-29 14:23:52 +0200
commita27ce1524d801d2742a2bdb6ec1da45126d64353 (patch)
tree64123c4e17dc1776aa0a7cd65ee01d49d3e7d978 /perllib/FixMyStreet/Roles/ConfirmValidation.pm
parent377bd96aab7cad3434185c30eb908c9da447fe40 (diff)
parent2773c60226b9370fe8ee00f7b205b571bb87c3b5 (diff)
Merge tag 'v3.0.1' into fiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/Roles/ConfirmValidation.pm')
-rw-r--r--perllib/FixMyStreet/Roles/ConfirmValidation.pm8
1 files changed, 7 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Roles/ConfirmValidation.pm b/perllib/FixMyStreet/Roles/ConfirmValidation.pm
index 776230287..27592b33c 100644
--- a/perllib/FixMyStreet/Roles/ConfirmValidation.pm
+++ b/perllib/FixMyStreet/Roles/ConfirmValidation.pm
@@ -17,6 +17,8 @@ Confirm field lengths.
has max_report_length => ( is => 'ro', default => 2000 );
+has max_title_length => ( is => 'ro', default => 0 );
+
sub report_validation {
my ($self, $report, $errors) = @_;
@@ -24,10 +26,14 @@ sub report_validation {
$errors->{name} = sprintf( _('Names are limited to %d characters in length.'), 50 );
}
- if ( length( $report->user->phone ) > 20 ) {
+ if ( $report->user->phone && length( $report->user->phone ) > 20 ) {
$errors->{phone} = sprintf( _('Phone numbers are limited to %s characters in length.'), 20 );
}
+ if ( $self->max_title_length > 0 && length( $report->title ) > $self->max_title_length ) {
+ $errors->{title} = sprintf( _('Summaries are limited to %d characters in length. Please shorten your summary'), 50 );
+ }
+
if ( length( $report->detail ) > $self->max_report_length ) {
$errors->{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), $self->max_report_length );
}