Skip to content

Conversation

@tchryssos
Copy link
Contributor

Overview

This PR adds the ability to pass custom validation objects to specific inputs in addition to the validations already included on the top level of the form. This is important because form-level validations are not easy to change dynamically because of both memoization and the need for accessing values "after" the form is instantiated.

There are a few threads kind of about this on the rhf github, but the general conclusions seem to be "you need to be able to access the getValues function when you create your validation rules" and "inlining on the register itself is the place to do wonky stuff".

Since our connected inputs don't actually do the registering themselves and instead hand that responsibility off to the useField hook, I have modified the useField hook to accept customValidations which can be passed to the FormGroup or the input itself. In either case, the custom rules will trickle into useField and successfully MERGE those rules with the ones coming from the form, with customValidations taking priority (since one might want to override a form level rule but the opposite seems unlikely to me).

PR Checklist

  • Related to JIRA ticket: https://skillsoftdev.atlassian.net/browse/WPLAT-3458. This ticket is actually about the VM configurator UX, but this is required to fix that
  • I have run this code to verify it works
  • This PR includes unit tests for the code change
  • This PR includes testing instructions tests for the code change
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing Instructions

Don't make me tap the sign.

  1. See that the tests pass

PR Links and Envs

Repository PR Link
Monolith Monolith PR
Mono Mono PR

@nx-cloud
Copy link

nx-cloud bot commented Jan 27, 2026

View your CI Pipeline Execution ↗ for commit 85b1420


☁️ Nx Cloud last updated this comment at 2026-01-27 19:02:18 UTC

@codecov
Copy link

codecov bot commented Jan 27, 2026

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants