Skip to content

damoeb/ng-typesafe-form-validation

Repository files navigation

Angular Typesafe Form Validation

The idea is to link the validate that the FormControls respect the types of the mapped entity. The formGroup will return an object with the defined types of the controls.

export type TypedFormControls<TControl> = {
  [K in keyof TControl]: FormControl<TControl[K]> | FormGroup<TypedFormControls<TControl[K]>>;
};

Example:

    this.addressFormGroup = new FormGroup<TypedFormControls<MyAddress>>({
      street: new FormControl(
        '',
        Validators.required
      ),
      streetNr: new FormControl(1) as FormControl<number>,
      plz: new FormControl<number>(0, Validators.required),
    });

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published