Skip to content

Commit 2aac92d

Browse files
committed
docs: apply prefer/avoid blocks in UI with comments
Apply inline comments with proper Prefer and Avoid UI blocks so guidance is more visible and consistent across the documentation.
1 parent b275206 commit 2aac92d

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

adev/src/content/guide/forms/signals/custom-controls.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,17 @@ When you add `min()` and `max()` validation rules to the schema, the FormField d
416416

417417
IMPORTANT: Don't implement validation logic in your control. Define validation rules in the form schema and let your control display the results:
418418

419-
```typescript
419+
```ts {avoid}
420420
// Avoid: Validation in control
421421
export class BadControl implements FormValueControl<string> {
422422
value = model<string>('');
423423
isValid() {
424424
return this.value().length >= 8;
425425
} // Don't do this!
426426
}
427+
```
427428

429+
```ts {prefer}
428430
// Good: Validation in schema, control displays results
429431
accountForm = form(this.accountModel, (schemaPath) => {
430432
minLength(schemaPath.password, 8, {message: 'Password must be at least 8 characters'});

adev/src/content/guide/forms/signals/models.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,16 @@ const usernameField = loginForm.username;
7474

7575
Form models should provide initial values for all fields you want to include in the field tree.
7676

77-
```ts
77+
```ts {prefer}
7878
// Good: All fields initialized
7979
const userModel = signal({
8080
name: '',
8181
email: '',
8282
age: 0,
8383
});
84+
```
8485

86+
```ts {avoid}
8587
// Avoid: Missing initial value
8688
const userModel = signal({
8789
name: '',

0 commit comments

Comments
 (0)