Skip to content
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

Add error-field to force invalid form #58

Merged
merged 4 commits into from
Sep 30, 2024
Merged

Add error-field to force invalid form #58

merged 4 commits into from
Sep 30, 2024

Conversation

qroll
Copy link
Contributor

@qroll qroll commented Sep 19, 2024

Changes

  • A field that when present, forces the form to be invalid
  • Exposes an error rule to customise the message
  • [delete] branch

Changelog entry

  • Add support for error-field

@weili-govtech
Copy link
Contributor

can we update it according to the changes in FEE?

  • tighten validation type
  • add children

@qroll
Copy link
Contributor Author

qroll commented Sep 25, 2024

the change to let custom rules extend IUnitNumberFieldValidationRule actually ended up causing more issues

  • on Typescript 4, I get this error
  • in yup-helper.ts, the rules couldn't be recognised due to the intersection of e.g. IUnitNumberFieldValidationRule | IYupValidationRule stripping away non-common properties

in the end I excluded the error field from TFieldValidation because it doesn't contribute to the typical rule evaluation anyway

@@ -220,7 +222,7 @@ export type TComponentSchema<V = undefined> =
| IWrapperSchema
| IElementSchema
| ICustomComponentSchema;
export type TFieldValidation = TFieldSchema["validation"];
export type TFieldValidation = Exclude<TFieldSchema, IErrorFieldSchema>["validation"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not needed, instead the rest of the custom rules in schemas should extend from IYupValidation (looks like we really missed this out)

@weili-govtech weili-govtech merged commit 081bc43 into main Sep 30, 2024
1 check passed
@weili-govtech weili-govtech deleted the MOL-16655 branch September 30, 2024 15:46
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