ngx-vest-forms 2.0.0-beta.3 → 2.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -54,7 +54,7 @@ npm install ngx-vest-forms
54
54
  > only(field); // only(undefined) safely runs all tests
55
55
  > ```
56
56
  >
57
- > Why: Conditional `only()` corrupts Vest's execution tracking and breaks `omitWhen` + `validationConfig`.
57
+ > Why: Conditional `only()` breaks Vest's change detection mechanism and causes timing issues with `omitWhen` + `validationConfig` in ngx-vest-forms.
58
58
  > See the [Migration Guide](./docs/migration/MIGRATION-v1.x-to-v2.0.0.md#1-unconditional-only-pattern-required-critical).
59
59
  >
60
60
  > Selector prefix: use `ngx-` (recommended). The legacy `sc-` works in v2.x but is deprecated and will be removed in v3.
@@ -118,7 +118,7 @@ That's all you need. The directive automatically creates controls, wires validat
118
118
  - **Vest.js validations** — Sync/async, conditional, composable patterns with `only(field)` optimization
119
119
  - **Error display modes** — Control when errors show: `on-blur`, `on-submit`, or `on-blur-or-submit` (default)
120
120
  - **Form state tracking** — Access touched, dirty, valid/invalid states for individual fields or entire form
121
- - **Error display helpers** — `ngx-control-wrapper`, tokens, and `FormErrorDisplayDirective` for consistent UX
121
+ - **Error display helpers** — `ngx-control-wrapper` component (recommended) or `FormErrorDisplayDirective` as hostDirective for custom wrappers
122
122
  - **Cross-field dependencies** — `validationConfig` for field-to-field triggers, `ROOT_FORM` for form-level rules
123
123
  - **Utilities** — Field paths, field clearing, validation config builder
124
124
 
@@ -134,7 +134,7 @@ providers: [
134
134
  { provide: NGX_ERROR_DISPLAY_MODE_TOKEN, useValue: 'on-blur-or-submit' }
135
135
  ]
136
136
 
137
- // Or per-field via control wrapper
137
+ // Recommended: Use ngx-control-wrapper component
138
138
  <ngx-control-wrapper [errorDisplayMode]="'on-blur'">
139
139
  <input name="email" [ngModel]="formValue().email" />
140
140
  </ngx-control-wrapper>
@@ -235,8 +235,12 @@ Manually trigger validation when form structure changes between **input fields a
235
235
 
236
236
  **NOT needed when**: Switching between different input fields (value changes trigger validation automatically).
237
237
 
238
+ **IMPORTANT**: `triggerFormValidation()` only re-runs validation logic—it does NOT mark fields as touched or show errors.
239
+
240
+ > **Note on form submission**: With the default `on-blur-or-submit` error display mode, errors are shown automatically when you submit via `(ngSubmit)`. The form automatically calls `markAllAsTouched()` internally. You only need to call `markAllAsTouched()` manually for special cases like multiple forms with one submit button.
241
+
238
242
  ```typescript
239
- // Example: Switching from input to paragraph
243
+ // Structure change: Re-run validation
240
244
  @if (type() === 'typeA') {
241
245
  <input name="fieldA" [ngModel]="formValue().fieldA" />
242
246
  } @else {
@@ -245,7 +249,23 @@ Manually trigger validation when form structure changes between **input fields a
245
249
 
246
250
  onTypeChange(newType: string) {
247
251
  this.formValue.update(v => ({ ...v, type: newType }));
248
- this.vestForm.triggerFormValidation(); // Only needed for structure changes
252
+ this.vestForm.triggerFormValidation(); // Re-runs validation, doesn't show errors
253
+ }
254
+
255
+ // Standard form submission - NO manual call needed!
256
+ // Errors shown automatically via (ngSubmit) with default on-blur-or-submit mode
257
+ <form ngxVestForm (ngSubmit)="save()">
258
+ <!-- ... -->
259
+ <button type="submit">Submit</button>
260
+ </form>
261
+
262
+ // Multiple forms with one button - NEED manual markAllAsTouched()
263
+ submitBoth() {
264
+ this.form1().markAllAsTouched();
265
+ this.form2().markAllAsTouched();
266
+ if (this.form1().valid && this.form2().valid) {
267
+ // Submit logic
268
+ }
249
269
  }
250
270
  ```
251
271