diff options
Diffstat (limited to 'perllib/FixMyStreet/Roles/ConfirmValidation.pm')
-rw-r--r-- | perllib/FixMyStreet/Roles/ConfirmValidation.pm | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Roles/ConfirmValidation.pm b/perllib/FixMyStreet/Roles/ConfirmValidation.pm index 6474c94d1..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) = @_; @@ -28,6 +30,10 @@ sub report_validation { $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 ); } |