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

Can't bind to 'validateRootForm' since it isn't a known property of 'form'. #13

Open
sysmat opened this issue Dec 22, 2024 · 0 comments

Comments

@sysmat
Copy link

sysmat commented Dec 22, 2024

  • ng 19, "ngx-vest-forms": "^1.1.0",
<form
      scVestForm
      [formShape]="shape"
      [suite]="suite"
      [validateRootForm]="true"
      (formValueChange)="formValue.set($event)"
      (validChange)="formValid.set($event)"
      (ngSubmit)="onSubmit()">

<div
        class="w-full"
        ngModelGroup="generalInfo"
        sc-control-wrapper>
        <div sc-control-wrapper>
          <label for="name">First name</label>
          <input
            class="input input-bordered input-primary"
            type="text"
            name="firstName"
            [ngModel]="formValue().generalInfo?.firstName" />
        </div>
<p>Valid: {{ formValid() }}</p>
  • error: Can't bind to 'validateRootForm' since it isn't a known property of 'form'.
  • no suites ever run, so validation is true all the time
export const myFormModelSuite = staticSuite((model: MyFormModel, field?: string) => {
  if (field) {
    // Needed to not run every validation every time
    only(field);
  }
  test('firstName', 'First name is required', () => {
    enforce(model.generalInfo?.firstName).isNotBlank();
  });
  test('firstName', 'First name is to short', () => {
    console.log('model.generalInfo?.firstName', model.generalInfo?.firstName);
    enforce(model.generalInfo?.firstName).longerThanOrEquals(4);
  });
  test('lastName', 'Last name is required', () => {
    enforce(model.generalInfo?.lastName).isNotBlank();
  });
});
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

No branches or pull requests

1 participant