Skip to content

feat(signal-forms): allow validation logic to return null and false #62657

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

Merged
merged 3 commits into from
Jul 16, 2025

Conversation

mmalerba
Copy link
Contributor

Something that's come up a few times during development of this prototype is that it would be nice to allow returning values like null and false from validation logic functions. This helps people write more concise logic without the need for extra if blocks or ternaries. e.g.:

validate(p.someNumber, ({value}) => value() > 10 && ValidationError.custom({kind: 'too-high'}))

We've also seen LLMs trip up and return null at the end of the validation function if there are no errors, rather than return undefined. It makes sense that either of these should work to indicate no error.

@mmalerba mmalerba requested review from leonsenft, kirjs and alxhub July 15, 2025 22:19
@ngbot ngbot bot added this to the Backlog milestone Jul 15, 2025
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Jul 15, 2025
@mmalerba mmalerba requested a review from leonsenft July 16, 2025 18:36
@mmalerba
Copy link
Contributor Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the forms validation logic to allow null and false to be returned from validation functions, indicating no errors. This change simplifies validation code and improves developer experience. The implementation includes updates to type definitions, refactoring of ArrayMergeLogic, and the addition of a new test case. I've provided feedback addressing a potential runtime error and suggesting code cleanup for improved clarity.

@mmalerba mmalerba merged commit ebb6786 into angular:prototype/signal-forms Jul 16, 2025
11 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: forms detected: feature PR contains a feature commit
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants