diff options
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Oxfordshire.pm | 12 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 20 | ||||
-rw-r--r-- | templates/web/oxfordshire/footer_extra_js.html | 1 | ||||
-rw-r--r-- | web/cobrands/fixmystreet-uk-councils/council_validation_rules.js | 10 |
4 files changed, 43 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index 9c1e541d4..bc85bb090 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -17,6 +17,18 @@ sub report_validation { $errors->{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), 1700 ); } + if ( length( $report->name ) > 70 ) { + $errors->{name} = sprintf( 'Names are limited to %d characters in length.', 70 ); + } + + if ( length( $report->user->phone ) > 30 ) { + $errors->{phone} = sprintf( 'Phone numbers are limited to %s characters in length.', 30 ); + } + + if ( length( $report->user->email ) > 50 ) { + $errors->{username} = sprintf( 'Emails are limited to %s characters in length.', 50 ); + } + return $errors; } diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 8290faac0..6dc659c19 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -594,6 +594,26 @@ foreach my $test ( changes => { }, errors => [ 'Please enter a subject', 'Please enter some details', 'Names are limited to 40 characters in length.' ], }, + { + msg => 'Oxfordshire validation', + pc => 'OX20 1SZ', + fields => { + title => '', + detail => '', + photo1 => '', + photo2 => '', + photo3 => '', + name => 'This is a really extraordinarily long name that definitely should fail validation', + may_show_name => '1', + username => 'bob.has.a.very.long.email@thisisalonghostname.example.com', + phone => '01234 5678910 09876 54321 ext 203', + category => 'Trees', + password_sign_in => '', + password_register => '', + }, + changes => { }, + errors => [ 'Please enter a subject', 'Please enter some details', 'Emails are limited to 50 characters in length.', 'Phone numbers are limited to 30 characters in length.', 'Names are limited to 70 characters in length.'], + }, ) { subtest "check form errors where $test->{msg}" => sub { diff --git a/templates/web/oxfordshire/footer_extra_js.html b/templates/web/oxfordshire/footer_extra_js.html index 5e24e7321..d95ed2c8e 100644 --- a/templates/web/oxfordshire/footer_extra_js.html +++ b/templates/web/oxfordshire/footer_extra_js.html @@ -4,4 +4,5 @@ version('/cobrands/oxfordshire/js.js'), version('/cobrands/oxfordshire/assets.js'), version('/cobrands/highways/assets.js'), + version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js'), ) %] diff --git a/web/cobrands/fixmystreet-uk-councils/council_validation_rules.js b/web/cobrands/fixmystreet-uk-councils/council_validation_rules.js index b9a4ed252..855d23de9 100644 --- a/web/cobrands/fixmystreet-uk-councils/council_validation_rules.js +++ b/web/cobrands/fixmystreet-uk-councils/council_validation_rules.js @@ -32,6 +32,16 @@ body_validation_rules = { detail: { required: true, maxlength: 1700 + }, + name: { + required: true, + maxlength: 70 + }, + phone: { + maxlength: 30 + }, + email: { + maxlength: 50 } } }; |