<commit_before>package OpenCloset::Donation::Controller::Root;
use Mojo::Base 'Mojolicious::Controller';

use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP qw();
use Email::Simple;
use Encode qw/encode_utf8/;

has schema => sub { shift->app->schema };

=head1 METHODS

=head2 index

    # home
    GET /

=cut

sub home {
}

=head2 guide1

    GET /guide1

=cut

sub guide1 {
}

=head2 guide2

    GET /guide2

=cut

sub guide2 {
}

=head2 add

    # add
    GET /new

=cut

sub add {
}

=head2 create

    # create
    POST /

=cut

sub create {
    my $self = shift;
    my $v    = $self->validation;

    $v->required('name');
    $v->optional('ever-donate');
    $v->optional('ever-use');
    $v->optional('birth-date')->like(qr/\d{4}-\d{2}-\d{2}/); # YYYY-mm-dd
    $v->optional('gender');
    $v->required('phone')->like(qr/^01[0-9]{3}-\d{4}-\d{4}$/);
    $v->required('email')->email;
    $v->required('address1');
    $v->required('address2');
    $v->required('address3');
    $v->optional('category');
    $v->optional('quantity');
    $v->optional('terms');
    $v->optional('talent-donation');
    $v->optional('talent');

    if ( $v->has_error ) {
        my $failed = $v->failed;
        return $self->error( 400, 'Parameter Validation Failed: ' . join( ', ', @$failed ) );
    }

    my $name            = $v->param('name');
    my $ever_donate     = $v->param('ever-donate');
    my $ever_use        = $v->param('ever-use');
    my $birth_date      = $v->param('birth-date');
    my $gender          = $v->param('gender');
    my $phone           = $v->param('phone');
    my $email           = $v->param('email');<commit_msg>Fix phone regex<commit_after>package OpenCloset::Donation::Controller::Root;
use Mojo::Base 'Mojolicious::Controller';

use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP qw();
use Email::Simple;
use Encode qw/encode_utf8/;

has schema => sub { shift->app->schema };

=head1 METHODS

=head2 index

    # home
    GET /

=cut

sub home {
}

=head2 guide1

    GET /guide1

=cut

sub guide1 {
}

=head2 guide2

    GET /guide2

=cut

sub guide2 {
}

=head2 add

    # add
    GET /new

=cut

sub add {
}

=head2 create

    # create
    POST /

=cut

sub create {
    my $self = shift;
    my $v    = $self->validation;

    $v->required('name');
    $v->optional('ever-donate');
    $v->optional('ever-use');
    $v->optional('birth-date')->like(qr/\d{4}-\d{2}-\d{2}/); # YYYY-mm-dd
    $v->optional('gender');
    $v->required('phone')->like(qr/^01[0-9]-\d{4}-\d{4}$/);
    $v->required('email')->email;
    $v->required('address1');
    $v->required('address2');
    $v->required('address3');
    $v->optional('category');
    $v->optional('quantity');
    $v->optional('terms');
    $v->optional('talent-donation');
    $v->optional('talent');

    if ( $v->has_error ) {
        my $failed = $v->failed;
        return $self->error( 400, 'Parameter Validation Failed: ' . join( ', ', @$failed ) );
    }

    my $name            = $v->param('name');
    my $ever_donate     = $v->param('ever-donate');
    my $ever_use        = $v->param('ever-use');
    my $birth_date      = $v->param('birth-date');
    my $gender          = $v->param('gender');
    my $phone           = $v->param('phone');
    my $email           = $v->param('email');
{'fraction_non_alphanumeric': 0.21349325337331335, 'fraction_numerical': 0.017091454272863568, 'mean_word_length': 2.6943521594684388, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4217821', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1217, 'n_words': 229}