Angular 21’s Signal Forms introduce a powerful, declarative approach to conditional validation that makes complex form logic much cleaner. Let’s break down the two main approaches: when and applyWhen.

The when Property: Single Rule Conditions

The when property allows you to conditionally apply a single validation rule based on other field values. Perfect for simple conditional requirements:

required(schemaPath.email, {
message: 'Email is required',
when: ({ valueOf }) => valueOf(schemaPath.sendViaEmail) === true,
});

Here, the email field is only required when the sendViaEmail checkbox is checked. The valueOf() function gives you reactive access to any field’s current value.

The applyWhen Function: Multiple Rule Conditions

When you need to apply…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help