-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: [M3-8932] - Add Form Validation Best Practices #11298
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy looks good and clear to me
Not sure why this test is failing, also you'll want to add a changeset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I do worry that the Linode Create example will unintentionally cause inexperienced developers to add unnecessary complexity, but can't say for sure.
We could consider using this example
manager/packages/manager/src/features/Images/ImagesLanding/ImageRegions/ManageImageRegionsForm.tsx
Lines 189 to 213 in d8812c4
const resolver: Resolver<UpdateImageRegionsPayload, Context> = async ( | |
values, | |
context | |
) => { | |
const availableRegionIds = context?.imageRegions | |
?.filter((r) => r.status === 'available') | |
.map((r) => r.region); | |
const isMissingAvailableRegion = !values.regions.some((regionId) => | |
availableRegionIds?.includes(regionId) | |
); | |
const availableRegionLabels = context?.regions | |
?.filter((r) => availableRegionIds?.includes(r.id)) | |
.map((r) => r.label); | |
if (isMissingAvailableRegion) { | |
const message = `At least one available region must be present (${availableRegionLabels?.join( | |
', ' | |
)}).`; | |
return { errors: { regions: { message, type: 'validate' } }, values }; | |
} | |
return { errors: {}, values }; | |
}; |
but it may not be complex enough 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving pending changeset is added.
re: Banks' concern:
worry that the Linode Create example will unintentionally cause inexperienced developers to add unnecessary complexity, but can't say for sure.
What if we used Images for the code snippet, but then said something like: 'for a more complex example, see Linode Create' and linked?
Coverage Report: ✅ |
Cloud Manager UI test results🔺 2 failing tests on test run #3 ↗︎
Details
TroubleshootingUse this command to re-run the failing tests: yarn cy:run -s "cypress/e2e/core/linodes/linode-storage.spec.ts,cypress/e2e/core/linodes/linode-storage.spec.ts" |
Description 📝
Currently, form validation implementations vary across the application. We need to establish a pattern for extending API validation schemas that maintains a clear separation between API contract validation and UI-specific validation requirements.
Changes 🔄
Create documentation explaining:
Target release date 🗓️
12/10