Skip to content

Commit

Permalink
tried to make validations work, it was an incomplete success.
Browse files Browse the repository at this point in the history
  • Loading branch information
horatiorosa committed Oct 21, 2024
1 parent 4a716ab commit 64a0692
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,38 @@
/>
</Ui::Question>
<Ui::Question @required={{true}} as |Q|>
<Q.Label>
<Q.Label data-test-projects-new-borough-dropdown>
Borough
</Q.Label>
<PowerSelect
<PowerSelect
supportsDataTestProperties={{true}}
@attribute='borough'
@options={{@boroughOptions}}
@onChange={{@onBoroughChange}}
@selected={{@selectedBorough}}
@searchField='label'
data-test-id='project-new-borough-dropdown'
@placeholder='select a borough' as |borough| >
{{borough.label}}
</PowerSelect>
</Ui::Question>
<Ui::Question @required={{true}} as |Q|>
<Q.Label>
<Q.Label data-test-projects-new-applicant-type>
Applicant Type
</Q.Label>
<p class='q-help'>
Identify if you represent a public agency or are a private entity.
</p>
<PowerSelect
<PowerSelect
supportsDataTestProperties={{true}}
@attribute='dcpApplicantType'
@options={{@applicantOptions}}
@onChange={{@onApplicantTypeSelection}}
@selected={{@selectedApplicantType}}
@searchField='label'
@placeholder='select applicant type' as |applicantType| >
{{applicantType.label}}
@searchField='label'
data-test-id='projects-new-applicant-type'
@placeholder='select applicant type' as |dcpApplicantType| >
{{dcpApplicantType.label}}
</PowerSelect>
</Ui::Question>
</form.Section>
Expand Down
52 changes: 32 additions & 20 deletions client/app/validations/submittable-projects-new-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,109 +9,121 @@ 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",
}),
],
primaryContactLastName: [
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",
}),
],
primaryContactEmail: [
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",
}),
],
primaryContactPhone: [
validateLength({
min: 0,
max: 10,
message: 'Text is too long (max {max} characters)',
message: "Text is too long (max {max} characters)",
}),
],
applicantFirstName: [
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",
}),
],
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: [
validatePresence({
presence: true,
message: "Please select a Borough",
}),
],
dcpApplicantType: [
validatePresence({
presence: true,
message: "Please select an Applicant Type",
}),
],
};

0 comments on commit 64a0692

Please sign in to comment.