Skip to content

Commit

Permalink
form validations and messaging for dropdowns working as per specs
Browse files Browse the repository at this point in the history
  • Loading branch information
horatiorosa committed Oct 29, 2024
1 parent cfb56c5 commit a2a9c82
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
@placeholder='select a borough' as |borough|>
{{borough.label}}
</PowerSelect>
{{#if form.errors.borough}}
{{#each form.errors.borough.validation as |message|}}
<div class="form-error is-visible" data-test-validation-message="select a borough">{{message}}</div>
{{/each}}
{{/if}}
</Ui::Question>

<Ui::Question @required={{true}} as |Q|>
<Q.Label data-test-projects-new-applicant-type>
Applicant Type
Expand All @@ -48,6 +52,12 @@
@placeholder='select applicant type' as |dcpApplicantType| >
{{dcpApplicantType.label}}
</PowerSelect>
{{#if form.errors.applicantType}}
{{#each form.errors.applicantType.validation as |message|}}
<div class="form-error is-visible" data-test-validation-message="select an Applicant Type"> {{message}}
</div>
{{/each}}
{{/if}}
</Ui::Question>
</form.Section>
{{/let}}
Expand Down
42 changes: 21 additions & 21 deletions client/app/validations/submittable-projects-new-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,109 +9,109 @@ export default {
validateLength({
min: 0,
max: 50,
message: 'Text is too long (max {max} characters)',
message: "Text is too long (max {max} characters)",

Check failure on line 12 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote

Check failure on line 12 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote
}),
validatePresence({
presence: true,
message: 'This field is required',
message: "This field is required",

Check failure on line 16 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote

Check failure on line 16 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote
}),
],
primaryContactLastName: [
validateLength({
min: 0,
max: 50,
message: 'Text is too long (max {max} characters)',
message: "Text is too long (max {max} characters)",

Check failure on line 23 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote

Check failure on line 23 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote
}),
validatePresence({
presence: true,
message: 'This field is required',
message: "This field is required",

Check failure on line 27 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote

Check failure on line 27 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote
}),
],
primaryContactEmail: [
validateLength({
min: 0,
max: 50,
message: 'Text is too long (max {max} characters)',
message: "Text is too long (max {max} characters)",

Check failure on line 34 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote

Check failure on line 34 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote
}),
validatePresence({
presence: true,
message: 'This field is required',
message: "This field is required",

Check failure on line 38 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote

Check failure on line 38 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote
}),
validateFormat({
type: 'email',
type: "email",

Check failure on line 41 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote

Check failure on line 41 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote
// Set allowBlank=true so that the validation message
// only appears after user first types something.
// This field still indicates it is 'required'
// through validatePresence
allowBlank: true,
message: 'Must be a valid email address',
message: "Must be a valid email address",

Check failure on line 47 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote

Check failure on line 47 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote
}),
],
primaryContactPhone: [
validateLength({
min: 0,
max: 10,
message: 'Text is too long (max {max} characters)',
message: "Text is too long (max {max} characters)",

Check failure on line 54 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote

Check failure on line 54 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote
}),
],
applicantFirstName: [
validateLength({
min: 0,
max: 50,
message: 'Text is too long (max {max} characters)',
message: "Text is too long (max {max} characters)",

Check failure on line 61 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote

Check failure on line 61 in client/app/validations/submittable-projects-new-form.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Strings must use singlequote
}),
validatePresence({
presence: true,
message: 'This field is required',
message: "This field is required",
}),
],
applicantLastName: [
validateLength({
min: 0,
max: 50,
message: 'Text is too long (max {max} characters)',
message: "Text is too long (max {max} characters)",
}),
validatePresence({
presence: true,
message: 'This field is required',
message: "This field is required",
}),
],
applicantEmail: [
validateLength({
min: 0,
max: 50,
message: 'Text is too long (max {max} characters)',
message: "Text is too long (max {max} characters)",
}),
validatePresence({
presence: true,
message: 'This field is required',
message: "This field is required",
}),
validateFormat({
type: 'email',
type: "email",
// Set allowBlank=true so that the validation message
// only appears after user first types something.
// This field still indicates it is 'required'
// through validatePresence
allowBlank: true,
message: 'Must be a valid email address',
message: "Must be a valid email address",
}),
],
applicantPhone: [
validateLength({
min: 0,
max: 10,
message: 'Text is too long (max {max} characters)',
message: "Text is too long (max {max} characters)",
}),
],
projectName: [
validateLength({
min: 0,
max: 50,
message: 'Text is too long (max {max} characters)',
message: "Text is too long (max {max} characters)",
}),
validatePresence({
presence: true,
message: 'This field is required',
message: "This field is required",
}),
],
borough: [
Expand All @@ -120,7 +120,7 @@ export default {
message: 'Please select a Borough',
}),
],
dcpApplicantType: [
applicantType: [
validatePresence({
presence: true,
message: 'Please select an Applicant Type',
Expand Down

0 comments on commit a2a9c82

Please sign in to comment.