<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package FixMyStreet::App::Form::Waste::UPRN;

use utf8;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler';

use mySociety::PostcodeUtil qw(is_valid_postcode);

has '+field_name_space' =&gt; ( default =&gt; 'FixMyStreet::App::Form::Field' );

has cobrand =&gt; ( is =&gt; 'ro', weak_ref =&gt; 1 );

has '+name' =&gt; ( default =&gt; 'uprn' );

has_field postcode =&gt; (
    required =&gt; 1,
    type =&gt; 'Postcode',
    validate_method =&gt; sub {
        my $self = shift;
        return if $self-&gt;has_errors; # Called even if already failed
        my $data = $self-&gt;form-&gt;cobrand-&gt;bin_addresses_for_postcode($self-&gt;value);
        if (!@$data) {
            my $error = 'Sorry, we did not find any results for that postcode';
            if ($self-&gt;form-&gt;cobrand-&gt;moniker eq 'peterborough') {
                $error = 'Unfortunately this postcode is not in Peterborough City Councilâ€™s local area. Please contact your local council.';
            }
            $self-&gt;add_error($error);
        }
        push @$data, { value =&gt; 'missing', label =&gt; 'I canâ€™t find my address' };
        $self-&gt;value($data);
    },
    tags =&gt; { autofocus =&gt; 1 },
);

has_field go =&gt; (
    type =&gt; 'Submit',
    value =&gt; 'Go',
    element_attr =&gt; { class =&gt; 'govuk-button' },
);

__PACKAGE__-&gt;meta-&gt;make_immutable;

1;
</pre></body></html>