Skip to content

Commit

Permalink
Merge branch '4911-update-name-validation' into qa
Browse files Browse the repository at this point in the history
  • Loading branch information
shaun-technovation committed Sep 24, 2024
2 parents 608b324 + 9663d58 commit 64d39c9
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

<div class="formulate-input-wrapper name-group">
<FormulateInput name="firstName" id="firstName" type="text" label="First Name" placeholder="First Name"
:validation="[['required'], ['matches', /[a-zA-Z]/]]" :validation-messages="{
matches: 'Must contain at least one alphabetical character.'
:validation="[['required'], ['matches', /^[^.-].*/]]" :validation-messages="{
matches: 'Must start with an alphabetical character.'
}" validation-name="First name" @keyup="checkValidation" @blur="checkValidation" class="flex-grow pr-2" />

<FormulateInput name="lastName" id="lastName" type="text" label="Last Name" placeholder="Last Name"
:validation="[['required'], ['matches', /[a-zA-Z]/]]" :validation-messages="{
matches: 'Must contain at least one alphabetical character.'
:validation="[['required'], ['matches', /^[^.-].*/]]" :validation-messages="{
matches: 'Must start with an alphabetical character.'
}" validation-name="Last name" @keyup="checkValidation" @blur="checkValidation" class="flex-grow pl-2" />
</div>

Expand Down
16 changes: 8 additions & 8 deletions app/javascript/new_registration/components/JudgeStepTwo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

<div class="formulate-input-wrapper name-group">
<FormulateInput name="firstName" id="firstName" type="text" label="First Name" placeholder="First Name"
:validation="[['required'], ['matches', /[a-zA-Z]/]]" :validation-messages="{
matches: 'Must contain at least one alphabetical character.'
:validation="[['required'], ['matches', /^[^.-].*/]]" :validation-messages="{
matches: 'Must start with an alphabetical character.'
}" validation-name="First name" @keyup="checkValidation" @blur="checkValidation" class="flex-grow pr-2" />

<FormulateInput name="lastName" id="lastName" type="text" label="Last Name" placeholder="Last Name"
:validation="[['required'], ['matches', /[a-zA-Z]/]]" :validation-messages="{
matches: 'Must contain at least one alphabetical character.'
:validation="[['required'], ['matches', /^[^.-].*/]]" :validation-messages="{
matches: 'Must start with an alphabetical character.'
}" validation-name="Last name" @keyup="checkValidation" @blur="checkValidation" class="flex-grow pl-2" />
</div>

Expand All @@ -37,8 +37,8 @@
@keyup="checkValidation" @blur="checkValidation" />

<p class="italic text-sm -mt-6 mb-8" style="margin-top: -12px;">
Your phone number will be shared with the Technovation Ambassador for your region and may be used to contact you
regarding volunteer opportunities. Providing your phone number is optional.
Your phone number will be shared with the Technovation Ambassador for your region and may be used to contact
you regarding volunteer opportunities. Providing your phone number is optional.
</p>

<FormulateInput name="gender" :options="genderOptions" type="select" placeholder="Select an option"
Expand All @@ -58,8 +58,8 @@
</h4>

<FormulateInput name="judgeTypes" id="judgeTypes" type="checkbox" :options="judgeTypeOptions"
validation="required" :validation-messages="{ required: 'This field is required.' }" @keyup="checkValidation"
@blur="checkValidation" @input="checkValidation" />
validation="required" :validation-messages="{ required: 'This field is required.' }"
@keyup="checkValidation" @blur="checkValidation" @input="checkValidation" />
</div>
</div>
</div>
Expand Down
16 changes: 8 additions & 8 deletions app/javascript/new_registration/components/MentorStepTwo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

<div class="formulate-input-wrapper name-group">
<FormulateInput name="firstName" id="firstName" type="text" label="First Name" placeholder="First Name"
:validation="[['required'], ['matches', /[a-zA-Z]/]]" :validation-messages="{
matches: 'Must contain at least one alphabetical character.'
:validation="[['required'], ['matches', /^[^.-].*/]]" :validation-messages="{
matches: 'Must start with an alphabetical character.'
}" validation-name="First name" @keyup="checkValidation" @blur="checkValidation" class="flex-grow pr-2" />

<FormulateInput name="lastName" id="lastName" type="text" label="Last Name" placeholder="Last Name"
:validation="[['required'], ['matches', /[a-zA-Z]/]]" :validation-messages="{
matches: 'Must contain at least one alphabetical character.'
:validation="[['required'], ['matches', /^[^.-].*/]]" :validation-messages="{
matches: 'Must start with an alphabetical character.'
}" validation-name="Last name" @keyup="checkValidation" @blur="checkValidation" class="flex-grow pl-2" />
</div>

Expand All @@ -35,8 +35,8 @@
@keyup="checkValidation" @blur="checkValidation" />

<p class="italic text-sm -mt-6 mb-8" style="margin-top: -12px;">
Your phone number will be shared with the Technovation Ambassador for your region and may be used to contact you
regarding volunteer opportunities. Providing your phone number is optional.
Your phone number will be shared with the Technovation Ambassador for your region and may be used to contact
you regarding volunteer opportunities. Providing your phone number is optional.
</p>

<FormulateInput name="mentorSchoolCompanyName" id="mentorSchoolCompanyName" type="text" label="Company Name"
Expand All @@ -52,8 +52,8 @@
</h4>

<FormulateInput name="mentorTypes" id="mentorTypes" type="checkbox" :options="mentorTypeOptions"
validation="required" :validation-messages="{ required: 'This field is required.' }" @keyup="checkValidation"
@blur="checkValidation" @input="checkValidation" />
validation="required" :validation-messages="{ required: 'This field is required.' }"
@keyup="checkValidation" @blur="checkValidation" @input="checkValidation" />
</div>

<div class="mentor-information" v-show="mentorProfileExpertiseOptions.length > 0">
Expand Down
12 changes: 6 additions & 6 deletions app/javascript/new_registration/components/StudentStepTwo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

<div class="formulate-input-wrapper name-group">
<FormulateInput name="firstName" id="firstName" type="text" label="First Name" placeholder="First Name"
:validation="[['required'], ['matches', /[a-zA-Z]/]]" :validation-messages="{
matches: 'Must contain at least one alphabetical character.'
:validation="[['required'], ['matches', /^[^.-].*/]]" :validation-messages="{
matches: 'Must start with an alphabetical character.'
}" validation-name="First name" @keyup="checkValidation" @blur="checkValidation" class="flex-grow pr-2" />

<FormulateInput name="lastName" id="lastName" type="text" label="Last Name" placeholder="Last Name"
:validation="[['required'], ['matches', /[a-zA-Z]/]]" :validation-messages="{
matches: 'Must contain at least one alphabetical character.'
:validation="[['required'], ['matches', /^[^.-].*/]]" :validation-messages="{
matches: 'Must start with an alphabetical character.'
}" validation-name="Last name" @keyup="checkValidation" @blur="checkValidation" class="flex-grow pl-2" />
</div>

Expand All @@ -28,8 +28,8 @@
<div class=" border-l-2 border-energetic-blue bg-blue-50 p-2 mb-8">
<p class="text-left">
The cutoff date used for division assignment is <strong>{{ divisionCutoffDate }}</strong>.
Based on the birthday you entered, {{ pronoun }} will be <strong>{{ ageByDivisionCutoff }}</strong> years old
by this date.
Based on the birthday you entered, {{ pronoun }} will be <strong>{{ ageByDivisionCutoff }}</strong> years
old by this date.
</p>
</div>

Expand Down
2 changes: 1 addition & 1 deletion app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def chapter_ambassador

validates :first_name, :last_name,
presence: true,
format: {with: /[A-Za-z]/, message: "must contain at least one alphabetical character"}
format: {with: /\A[^.-].*/, message: "must start with an alphabetical character"}

validates :date_of_birth, presence: true, if: -> { !is_a_judge? && !is_chapter_ambassador? }
validates :meets_minimum_age_requirement, inclusion: [true], if: -> { (is_a_judge? || is_chapter_ambassador?) && new_record? }
Expand Down
20 changes: 20 additions & 0 deletions spec/models/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@
end
end

context "when the first name contains a special character not at the beginning" do
before do
judge.first_name = "Billie-Jean"
end

it "is valid" do
expect(judge).to be_valid
end
end

describe "#last_name" do
let(:judge) { FactoryBot.create(:judge) }

Expand All @@ -164,6 +174,16 @@
expect(judge).not_to be_valid
end
end

context "when the last name contains a special character not at the beginning" do
before do
judge.last_name = "A."
end

it "is valid" do
expect(judge).to be_valid
end
end
end
end

Expand Down

0 comments on commit 64d39c9

Please sign in to comment.