### File

`src/lib/form-group.ts`

### Extends

`UntypedFormGroup`

### Index

###### Properties
Readonly controlId Public controls dirty$ Readonly disabled$ Readonly enabled$ Readonly errors Readonly errors$ Readonly status Readonly status$ Readonly statusChanges touch$ Readonly value Readonly value$ Readonly valueChanges
###### Methods
Public addControl Public contains Public disabledWhile Public enabledWhile Public get Public get Public get Public get Public get Public getControl Public getControl Public getControl Public getControl Public getControl Public getError Public getError Public getError Public getError Public getError Public getRawValue Public hasError Public hasError Public hasError Public hasError Public hasError Public hasErrorAndDirty Public hasErrorAndDirty Public hasErrorAndDirty Public hasErrorAndDirty Public hasErrorAndDirty Public hasErrorAndTouched Public hasErrorAndTouched Public hasErrorAndTouched Public hasErrorAndTouched Public hasErrorAndTouched Public markAllAsDirty Public markAllAsPristine Public markAllAsUntouched Public markAsDirty Public markAsPristine Public markAsTouched Public markAsUntouched Public mergeAsyncValidators Public mergeValidators Public patchValue Public patchValue Public patchValue Public removeControl Public reset Public select Public setAsyncValidators Public setControl Public setDisable Public setEnable Public setErrors Public setValidators Public setValue Public setValue Public setValue Public validateOn
###### Accessors
readonly controlPath fullControlPath

### Constructor

`constructor(controls: ExtractAbstractControl<KeyValueControls<T> | T>, options: FormGroupOptions)`
Defined in src/lib/form-group.ts:126
Parameters :
Name | Type | Optional
controls | `ExtractAbstractControl<KeyValueControls<T> | T>` | No
options | `FormGroupOptions` | No

### Properties

Readonly controlId
Type : `string`
Defined in src/lib/form-group.ts:102

Public controls
Type : `ExtractAbstractControl<KeyValueControls<T> | T>`
Defined in src/lib/form-group.ts:129

dirty$
Default value : `this.dirtyChanges.asObservable().pipe(distinctUntilChanged())`
Defined in src/lib/form-group.ts:94

Readonly disabled$
Default value : `controlDisabled$<T>(this)`
Defined in src/lib/form-group.ts:97

Readonly enabled$
Default value : `controlEnabled$<T>(this)`
Defined in src/lib/form-group.ts:98

Readonly errors
Type : `E | null`
Defined in src/lib/form-group.ts:85

Readonly errors$
Default value : `controlErrorChanges$<E>(this)`
Defined in src/lib/form-group.ts:100

Readonly status
Type : `ControlState`
Defined in src/lib/form-group.ts:87

Readonly status$
Default value : `controlStatusChanges$<T>(this)`
Defined in src/lib/form-group.ts:99

Readonly statusChanges
Type : `Observable<ControlState>`
Defined in src/lib/form-group.ts:88

touch$
Default value : `this.touchChanges.asObservable().pipe(distinctUntilChanged())`
Defined in src/lib/form-group.ts:93

Readonly value
Type : `T`
Defined in src/lib/form-group.ts:84

Readonly value$
Type : `Observable<T>`
Default value : `controlValueChanges$<T>(this)`
Defined in src/lib/form-group.ts:96

Readonly valueChanges
Type : `Observable<T>`
Defined in src/lib/form-group.ts:86

### Methods

Public addControl
`addControl(name: K, control: AbstractControl<>)`
Defined in src/lib/form-group.ts:183
Type parameters : K
Parameters :
Name | Type | Optional
name | `K` | No
control | `AbstractControl<>` | No
Returns : `void`

Public contains
`contains(controlName: ExtractStrings<T>)`
Defined in src/lib/form-group.ts:194
Parameters :
Name | Type | Optional
controlName | `ExtractStrings<T>` | No
Returns : `boolean`

Public disabledWhile
`disabledWhile(observable: Observable, options?: ControlOptions)`
Defined in src/lib/form-group.ts:267
Parameters :
Name | Type | Optional
observable | `Observable<boolean>` | No
options | `ControlOptions` | Yes
Returns : `Subscription`

Public enabledWhile
`enabledWhile(observable: Observable, options?: ControlOptions)`
Defined in src/lib/form-group.ts:274
Parameters :
Name | Type | Optional
observable | `Observable<boolean>` | No
options | `ControlOptions` | Yes
Returns : `Subscription`

Public get
`get(path: [K1])`
Defined in src/lib/form-group.ts:144
Type parameters : K1
Parameters :
Name | Type | Optional
path | `[K1]` | No
Returns : `AbstractControl<>`

Public get
`get(path: [K1, K2])`
Defined in src/lib/form-group.ts:145
Type parameters : K1 K2
Parameters :
Name | Type | Optional
path | `[K1, K2]` | No
Returns : `AbstractControl<>`

Public get
`get(path: [K1, K2, K3])`
Defined in src/lib/form-group.ts:148
Type parameters : K1 K2 K3
Parameters :
Name | Type | Optional
path | `[K1, K2, K3]` | No
Returns : `AbstractControl<>`

Public get
`get(path: string)`
Defined in src/lib/form-group.ts:153
Parameters :
Name | Type | Optional
path | `string` | No
Returns : `AbstractControl`

Public get
`get(path: any)`
Defined in src/lib/form-group.ts:154
Parameters :
Name | Type | Optional
path | `any` | No
Returns : `AbstractControl | null`

Public getControl
`getControl(prop1: P1)`
Defined in src/lib/form-group.ts:158
Type parameters : P1
Parameters :
Name | Type | Optional
prop1 | `P1` | No
Returns : `AbstractControl<>`

Public getControl
`getControl(prop1: P1, prop2: P2)`
Defined in src/lib/form-group.ts:159
Type parameters : P1 P2
Parameters :
Name | Type | Optional
prop1 | `P1` | No
prop2 | `P2` | No
Returns : `AbstractControl<>`

Public getControl
`getControl(prop1: P1, prop2: P2, prop3: P3)`
Defined in src/lib/form-group.ts:163
Type parameters : P1 P2 P3
Parameters :
Name | Type | Optional
prop1 | `P1` | No
prop2 | `P2` | No
prop3 | `P3` | No
Returns : `AbstractControl<>`

Public getControl
`getControl(prop1: P1, prop2: P2, prop3: P3, prop4: P4)`
Defined in src/lib/form-group.ts:168
Type parameters : P1 P2 P3 P4
Parameters :
Name | Type | Optional
prop1 | `P1` | No
prop2 | `P2` | No
prop3 | `P3` | No
prop4 | `P4` | No
Returns : `AbstractControl<>`

Public getControl
`getControl(...names: any)`
Defined in src/lib/form-group.ts:179
Parameters :
Name | Type | Optional
names | `any` | No
Returns : `AbstractControl<any>`

Public getError
`getError(errorCode: K, path?: [K1])`
Defined in src/lib/form-group.ts:375
Type parameters : K K1
Parameters :
Name | Type | Optional
errorCode | `K` | No
path | `[K1]` | Yes
Returns : `| null`

Public getError
`getError(errorCode: K, path?: [K1, K2])`
Defined in src/lib/form-group.ts:379
Type parameters : K K1 K2
Parameters :
Name | Type | Optional
errorCode | `K` | No
path | `[K1, K2]` | Yes
Returns : `| null`

Public getError
`getError(errorCode: K, path?: [K1, K2, K3])`
Defined in src/lib/form-group.ts:384
Type parameters : K K1 K2 K3
Parameters :
Name | Type | Optional
errorCode | `K` | No
path | `[K1, K2, K3]` | Yes
Returns : `| null`

Public getError
`getError(errorCode: K, path?: string)`
Defined in src/lib/form-group.ts:390
Type parameters : K
Parameters :
Name | Type | Optional
errorCode | `K` | No
path | `string` | Yes
Returns : `| null`

Public getError
`getError(errorCode: K, path?: any)`
Defined in src/lib/form-group.ts:391
Type parameters : K
Parameters :
Name | Type | Optional
errorCode | `K` | No
path | `any` | Yes
Returns : `| null`

Public getRawValue
`getRawValue()`
Defined in src/lib/form-group.ts:140
Returns : `T`

Public hasError
`hasError(errorCode: ExtractStrings<E>, path?: [K1])`
Defined in src/lib/form-group.ts:353
Type parameters : K1
Parameters :
Name | Type | Optional
errorCode | `ExtractStrings<E>` | No
path | `[K1]` | Yes
Returns : `boolean`

Public hasError
`hasError(errorCode: ExtractStrings<E>, path?: [K1, K2])`
Defined in src/lib/form-group.ts:357
Type parameters : K1 K2
Parameters :
Name | Type | Optional
errorCode | `ExtractStrings<E>` | No
path | `[K1, K2]` | Yes
Returns : `boolean`

Public hasError
`hasError(errorCode: ExtractStrings<E>, path?: [K1, K2, K3])`
Defined in src/lib/form-group.ts:361
Type parameters : K1 K2 K3
Parameters :
Name | Type | Optional
errorCode | `ExtractStrings<E>` | No
path | `[K1, K2, K3]` | Yes
Returns : `boolean`

Public hasError
`hasError(errorCode: ExtractStrings<E>, path?: string)`
Defined in src/lib/form-group.ts:366
Parameters :
Name | Type | Optional
errorCode | `ExtractStrings<E>` | No
path | `string` | Yes
Returns : `boolean`

Public hasError
`hasError(errorCode: ExtractStrings<E>, path?: any)`
Defined in src/lib/form-group.ts:367
Parameters :
Name | Type | Optional
errorCode | `ExtractStrings<E>` | No
path | `any` | Yes
Returns : `boolean`

Public hasErrorAndDirty
`hasErrorAndDirty(error: ExtractStrings<E>, prop1?: P1)`
Defined in src/lib/form-group.ts:425
Type parameters : P1
Parameters :
Name | Type | Optional
error | `ExtractStrings<E>` | No
prop1 | `P1` | Yes
Returns : `boolean`

Public hasErrorAndDirty
`hasErrorAndDirty(error: ExtractStrings<E>, prop1?: P1, prop2?: P2)`
Defined in src/lib/form-group.ts:429
Type parameters : P1 P2
Parameters :
Name | Type | Optional
error | `ExtractStrings<E>` | No
prop1 | `P1` | Yes
prop2 | `P2` | Yes
Returns : `boolean`

Public hasErrorAndDirty
`hasErrorAndDirty(error: ExtractStrings<E>, prop1?: P1, prop2?: P2, prop3?: P3)`
Defined in src/lib/form-group.ts:434
Type parameters : P1 P2 P3
Parameters :
Name | Type | Optional
error | `ExtractStrings<E>` | No
prop1 | `P1` | Yes
prop2 | `P2` | Yes
prop3 | `P3` | Yes
Returns : `boolean`

Public hasErrorAndDirty
`hasErrorAndDirty(error: ExtractStrings<E>, prop1?: P1, prop2?: P2, prop3?: P3, prop4?: P4)`
Defined in src/lib/form-group.ts:439
Type parameters : P1 P2 P3 P4
Parameters :
Name | Type | Optional
error | `ExtractStrings<E>` | No
prop1 | `P1` | Yes
prop2 | `P2` | Yes
prop3 | `P3` | Yes
prop4 | `P4` | Yes
Returns : `boolean`

Public hasErrorAndDirty
`hasErrorAndDirty(error: any, ...path: any)`
Defined in src/lib/form-group.ts:451
Parameters :
Name | Type | Optional
error | `any` | No
path | `any` | No
Returns : `boolean`

Public hasErrorAndTouched
`hasErrorAndTouched(error: ExtractStrings<E>, prop1?: P1)`
Defined in src/lib/form-group.ts:395
Type parameters : P1
Parameters :
Name | Type | Optional
error | `ExtractStrings<E>` | No
prop1 | `P1` | Yes
Returns : `boolean`

Public hasErrorAndTouched
`hasErrorAndTouched(error: ExtractStrings<E>, prop1?: P1, prop2?: P2)`
Defined in src/lib/form-group.ts:399
Type parameters : P1 P2
Parameters :
Name | Type | Optional
error | `ExtractStrings<E>` | No
prop1 | `P1` | Yes
prop2 | `P2` | Yes
Returns : `boolean`

Public hasErrorAndTouched
`hasErrorAndTouched(error: ExtractStrings<E>, prop1?: P1, prop2?: P2, prop3?: P3)`
Defined in src/lib/form-group.ts:404
Type parameters : P1 P2 P3
Parameters :
Name | Type | Optional
error | `ExtractStrings<E>` | No
prop1 | `P1` | Yes
prop2 | `P2` | Yes
prop3 | `P3` | Yes
Returns : `boolean`

Public hasErrorAndTouched
`hasErrorAndTouched(error: ExtractStrings<E>, prop1?: P1, prop2?: P2, prop3?: P3, prop4?: P4)`
Defined in src/lib/form-group.ts:409
Type parameters : P1 P2 P3 P4
Parameters :
Name | Type | Optional
error | `ExtractStrings<E>` | No
prop1 | `P1` | Yes
prop2 | `P2` | Yes
prop3 | `P3` | Yes
prop4 | `P4` | Yes
Returns : `boolean`

Public hasErrorAndTouched
`hasErrorAndTouched(error: any, ...path: any)`
Defined in src/lib/form-group.ts:421
Parameters :
Name | Type | Optional
error | `any` | No
path | `any` | No
Returns : `boolean`

Public markAllAsDirty
`markAllAsDirty()`
Defined in src/lib/form-group.ts:313
Returns : `void`

Public markAllAsPristine
`markAllAsPristine()`
Defined in src/lib/form-group.ts:317
Returns : `void`

Public markAllAsUntouched
`markAllAsUntouched()`
Defined in src/lib/form-group.ts:321
Returns : `void`

Public markAsDirty
`markAsDirty(opts?: OnlySelf)`
Defined in src/lib/form-group.ts:308
Parameters :
Name | Type | Optional
opts | `OnlySelf` | Yes
Returns : `void`

Public markAsPristine
`markAsPristine(opts?: OnlySelf)`
Defined in src/lib/form-group.ts:303
Parameters :
Name | Type | Optional
opts | `OnlySelf` | Yes
Returns : `void`

Public markAsTouched
`markAsTouched(opts?: OnlySelf)`
Defined in src/lib/form-group.ts:293
Parameters :
Name | Type | Optional
opts | `OnlySelf` | Yes
Returns : `void`

Public markAsUntouched
`markAsUntouched(opts?: OnlySelf)`
Defined in src/lib/form-group.ts:298
Parameters :
Name | Type | Optional
opts | `OnlySelf` | Yes
Returns : `void`

Public mergeAsyncValidators
`mergeAsyncValidators(validators: AsyncValidator)`
Defined in src/lib/form-group.ts:285
Parameters :
Name | Type | Optional
validators | `AsyncValidator` | No
Returns : `void`

Public mergeValidators
`mergeValidators(validators: Validator)`
Defined in src/lib/form-group.ts:281
Parameters :
Name | Type | Optional
validators | `Validator` | No
Returns : `void`

Public patchValue
`patchValue(valueOrObservable: Observable>, options?: ControlEventOptions)`
Defined in src/lib/form-group.ts:245
Parameters :
Name | Type | Optional
valueOrObservable | `Observable<Partial<T>>` | No
options | `ControlEventOptions` | Yes
Returns : `Subscription`

Public patchValue
`patchValue(valueOrObservable: Partial, options?: ControlEventOptions)`
Defined in src/lib/form-group.ts:249
Parameters :
Name | Type | Optional
valueOrObservable | `Partial<T>` | No
options | `ControlEventOptions` | Yes
Returns : `void`

Public patchValue
`patchValue(valueOrObservable: any, options?: ControlEventOptions)`
Defined in src/lib/form-group.ts:253
Parameters :
Name | Type | Optional
valueOrObservable | `any` | No
options | `ControlEventOptions` | Yes
Returns : `Subscription | void`

Public removeControl
`removeControl(name: ExtractStrings<T>)`
Defined in src/lib/form-group.ts:190
Parameters :
Name | Type | Optional
name | `ExtractStrings<T>` | No
Returns : `void`

Public reset
`reset(formState?: Partial, options?: ControlEventOptions)`
Defined in src/lib/form-group.ts:325
Parameters :
Name | Type | Optional
formState | `Partial<T>` | Yes
options | `ControlEventOptions` | Yes
Returns : `void`

Public select
`select(mapFn: (state: T) => void)`
Defined in src/lib/form-group.ts:136
Type parameters : R
Parameters :
Name | Type | Optional
mapFn | `function` | No
Returns : `Observable<R>`

Public setAsyncValidators
`setAsyncValidators(newValidator: AsyncValidator, updateValueAndValidity)`
Defined in src/lib/form-group.ts:339
Parameters :
Name | Type | Optional | Default value
newValidator | `AsyncValidator` | No |
updateValueAndValidity |  | No | `true`
Returns : `void`

Public setControl
`setControl(name: K, control: AbstractControl<>)`
Defined in src/lib/form-group.ts:198
Type parameters : K
Parameters :
Name | Type | Optional
name | `K` | No
control | `AbstractControl<>` | No
Returns : `void`

Public setDisable
`setDisable(disable, opts?: ControlEventOptions)`
Defined in src/lib/form-group.ts:459
Parameters :
Name | Type | Optional | Default value
disable |  | No | `true`
opts | `ControlEventOptions` | Yes |
Returns : `void`

Public setEnable
`setEnable(enable, opts?: ControlEventOptions)`
Defined in src/lib/form-group.ts:455
Parameters :
Name | Type | Optional | Default value
enable |  | No | `true`
opts | `ControlEventOptions` | Yes |
Returns : `void`

Public setErrors
`setErrors(errors: Partial | null, opts: EmitEvent)`
Defined in src/lib/form-group.ts:371
Parameters :
Name | Type | Optional | Default value
errors | `Partial<E> | null` | No |
opts | `EmitEvent` | No | `{}`
Returns : `any`

Public setValidators
`setValidators(newValidator: Validator, updateValueAndValidity)`
Defined in src/lib/form-group.ts:329
Parameters :
Name | Type | Optional | Default value
newValidator | `Validator` | No |
updateValueAndValidity |  | No | `true`
Returns : `void`

Public setValue
`setValue(valueOrObservable: Observable, options?: ControlEventOptions)`
Defined in src/lib/form-group.ts:205
Parameters :
Name | Type | Optional
valueOrObservable | `Observable<T>` | No
options | `ControlEventOptions` | Yes
Returns : `Subscription`

Public setValue
`setValue(valueOrObservable: T, options?: ControlEventOptions)`
Defined in src/lib/form-group.ts:209
Parameters :
Name | Type | Optional
valueOrObservable | `T` | No
options | `ControlEventOptions` | Yes
Returns : `void`

Public setValue
`setValue(valueOrObservable: any, options?: ControlEventOptions)`
Defined in src/lib/form-group.ts:210
Parameters :
Name | Type | Optional
valueOrObservable | `any` | No
options | `ControlEventOptions` | Yes
Returns : `any`

Public validateOn
`validateOn(observableValidation: Observable)`
Defined in src/lib/form-group.ts:349
Parameters :
Name | Type | Optional
observableValidation | `Observable<null | object>` | No
Returns : `any`

### Accessors

readonly
get `readonly()`
Defined in src/lib/form-group.ts:70
set `readonly(value: boolean)`
Defined in src/lib/form-group.ts:74
Parameters :
Name | Type | Optional
value | `boolean` | No
Returns : `void`

controlPath
get `controlPath()`
Defined in src/lib/form-group.ts:104

fullControlPath
get `fullControlPath()`
Defined in src/lib/form-group.ts:118

    import {
      isObservable,
      Observable,
      Subject,
      Subscription,
    } from 'rxjs';
    import { distinctUntilChanged } from 'rxjs/operators';
    import { UntypedFormGroup } from '@angular/forms';
    import {
      AbstractControl,
      AsyncValidator,
      ControlEventOptions,
      ControlOptions,
      ControlState,
      EmitEvent,
      ExtractAbstractControl,
      ExtractStrings,
      KeyValueControls,
      OnlySelf,
      ValidationErrors,
      Validator,
    } from './types';
    import {
      controlDisabled$,
      controlDisabledWhile,
      controlEnabled$,
      controlEnabledWhile,
      controlErrorChanges$,
      controlStatusChanges$,
      controlValueChanges$,
      disableControl,
      enableControl,
      hasErrorAndDirty,
      hasErrorAndTouched,
      markAllDirty,
      markAllPristine,
      markAllUntouched,
      mergeControlValidators,
      selectControlValue$,
      validateControlOn,
    } from './control-actions';
    import { coerceArray } from '@rxap/utilities';
    import {
      FormDefinition,
      FormGroupOptions,
      FormType,
    } from './model';

    export class RxapFormGroup<
      T = any,
      E extends ValidationErrors = any
    > extends UntypedFormGroup {
      /**
       * @internal
       */
      public get rxapFormDefinition():
        | (FormType<T> & FormDefinition<T>)
        | undefined {
        if (!this.parent) {
          return this._rxapFormDefinition;
        }
        if (this._rxapFormDefinition) {
          return this._rxapFormDefinition;
        }
        return (this.parent as any).rxapFormDefinition;
      }

      private _readonly = false;

      public get readonly(): boolean {
        return (this.parent as any)?.readonly ?? this._readonly;
      }

      public set readonly(value: boolean) {
        this._readonly = value;
        Object.values(this.controls ?? {}).forEach(control => (control as any).stateChanges?.next());
      }

      /**
       * @internal
       */
      private _rxapFormDefinition?: FormType<T> & FormDefinition<T>;

      override readonly value!: T;
      override readonly errors!: E | null;
      override readonly valueChanges!: Observable<T>;
      override readonly status!: ControlState;
      override readonly statusChanges!: Observable<ControlState>;

      private touchChanges = new Subject<boolean>();
      private dirtyChanges = new Subject<boolean>();

      touch$ = this.touchChanges.asObservable().pipe(distinctUntilChanged());
      dirty$ = this.dirtyChanges.asObservable().pipe(distinctUntilChanged());

      readonly value$: Observable<T> = controlValueChanges$<T>(this);
      readonly disabled$ = controlDisabled$<T>(this);
      readonly enabled$ = controlEnabled$<T>(this);
      readonly status$ = controlStatusChanges$<T>(this);
      readonly errors$ = controlErrorChanges$<E>(this);

      readonly controlId: string;

      public get controlPath(): string {
        const parent: any = this.parent;
        if (parent) {
          if (parent.controlPath) {
            if (parent === this.root) {
              return this.controlId;
            } else {
              return [ parent.controlPath, this.controlId ].join('.');
            }
          }
        }
        return '';
      }

      public get fullControlPath(): string {
        const parent: any = this.parent;
        if (parent) {
          if (parent.fullControlPath) {
            return [ parent.fullControlPath, this.controlId ].join('.');
          }
        }
        return this.controlId;
      }

      constructor(
        public override controls: ExtractAbstractControl<KeyValueControls<T>, T>,
        options: FormGroupOptions,
      ) {
        super(controls, options);
        this.controlId = options.controlId;
      }

      public select<R>(mapFn: (state: T) => R): Observable<R> {
        return selectControlValue$<T, R>(this, mapFn);
      }

      public override getRawValue(): T {
        return super.getRawValue();
      }

      public override get<K1 extends keyof T>(path: [ K1 ]): AbstractControl<T[K1]>;
      public override get<K1 extends keyof T, K2 extends keyof T[K1]>(
        path: [ K1, K2 ],
      ): AbstractControl<T[K1][K2]>;
      public override get<
        K1 extends keyof T,
        K2 extends keyof T[K1],
        K3 extends keyof T[K1][K2]
      >(path: [ K1, K2, K3 ]): AbstractControl<T[K1][K2][K3]>;
      public override get(path: string): AbstractControl;
      public override get(path: any): AbstractControl | null {
        return super.get(path);
      }

      public getControl<P1 extends keyof T>(prop1: P1): AbstractControl<T[P1]>;
      public getControl<P1 extends keyof T, P2 extends keyof T[P1]>(
        prop1: P1,
        prop2: P2,
      ): AbstractControl<T[P1][P2]>;
      public getControl<
        P1 extends keyof T,
        P2 extends keyof T[P1],
        P3 extends keyof T[P1][P2]
      >(prop1: P1, prop2: P2, prop3: P3): AbstractControl<T[P1][P2][P3]>;
      public getControl<
        P1 extends keyof T,
        P2 extends keyof T[P1],
        P3 extends keyof T[P1][P2],
        P4 extends keyof T[P1][P2][P3]
      >(
        prop1: P1,
        prop2: P2,
        prop3: P3,
        prop4: P4,
      ): AbstractControl<T[P1][P2][P3][P4]>;
      public getControl(...names: any): AbstractControl<any> {
        return this.get(names.join('.'));
      }

      public override addControl<K extends ExtractStrings<T>>(
        name: K,
        control: AbstractControl<T[K]>,
      ): void {
        super.addControl(name, control);
      }

      public override removeControl(name: ExtractStrings<T>): void {
        super.removeControl(name);
      }

      public override contains(controlName: ExtractStrings<T>): boolean {
        return super.contains(controlName);
      }

      public override setControl<K extends ExtractStrings<T>>(
        name: K,
        control: AbstractControl<T[K]>,
      ): void {
        super.setControl(name, control);
      }

      public override setValue(
        valueOrObservable: Observable<T>,
        options?: ControlEventOptions,
      ): Subscription;
      public override setValue(valueOrObservable: T, options?: ControlEventOptions): void;
      public override setValue(valueOrObservable: any, options?: ControlEventOptions): any {
        if (isObservable(valueOrObservable)) {
          return (valueOrObservable as Observable<T>).subscribe((value) =>
            // TODO : refactor RxapFormGroup to typed FormGroup
            super.setValue(value as any, options),
          );
        }

        super.setValue(valueOrObservable, options);
      }

      private _patchValue(value: T, options?: ControlEventOptions) {
        // Even though the `value` argument type doesn't allow `null` and `undefined` values, the
        // `patchValue` can be called recursively and inner data structures might have these values, so
        // we just ignore such cases when a field containing FormGroup instance receives `null` or
        // `undefined` as a value.
        if (value == null /* both `null` and `undefined` */) {
          return;
        }
        Object.keys(value).forEach(name => {
          // TODO : resolve type issue
          const controls = this.controls as any;
          if (controls[name]) {
            controls[name].patchValue(
              (value as any)[name],
              {
                ...(options ?? {}),
                onlySelf: true,
              },
            );
          }
        });
        this.updateValueAndValidity(options);
      }

      public override patchValue(
        valueOrObservable: Observable<Partial<T>>,
        options?: ControlEventOptions,
      ): Subscription;
      public override patchValue(
        valueOrObservable: Partial<T>,
        options?: ControlEventOptions,
      ): void;
      public override patchValue(
        valueOrObservable: any,
        options?: ControlEventOptions,
      ): Subscription | void {
        if (isObservable(valueOrObservable)) {
          return (valueOrObservable as Observable<T>).subscribe((value) =>
            // TODO : refactor RxapFormGroup to typed FormGroup
            super.patchValue(value as any, options),
          );
        }

        this._patchValue(valueOrObservable, options);
      }

      public disabledWhile(
        observable: Observable<boolean>,
        options?: ControlOptions,
      ): Subscription {
        return controlDisabledWhile(this, observable, options);
      }

      public enabledWhile(
        observable: Observable<boolean>,
        options?: ControlOptions,
      ): Subscription {
        return controlEnabledWhile(this, observable, options);
      }

      public mergeValidators(validators: Validator) {
        mergeControlValidators(this, validators);
      }

      public mergeAsyncValidators(validators: AsyncValidator) {
        this.setAsyncValidators([
          ...coerceArray(this.asyncValidator),
          ...coerceArray(validators),
        ]);
        this.updateValueAndValidity();
      }

      public override markAsTouched(opts?: OnlySelf): void {
        super.markAsTouched(opts);
        this.touchChanges.next(true);
      }

      public override markAsUntouched(opts?: OnlySelf): void {
        super.markAsUntouched(opts);
        this.touchChanges.next(false);
      }

      public override markAsPristine(opts?: OnlySelf): void {
        super.markAsPristine(opts);
        this.dirtyChanges.next(false);
      }

      public override markAsDirty(opts?: OnlySelf): void {
        super.markAsDirty(opts);
        this.dirtyChanges.next(true);
      }

      public markAllAsDirty(): void {
        markAllDirty(this);
      }

      public markAllAsPristine(): void {
        markAllPristine(this);
      }

      public markAllAsUntouched(): void {
        markAllUntouched(this);
      }

      public override reset(formState?: Partial<T>, options?: ControlEventOptions): void {
        super.reset(formState, options);
      }

      public override setValidators(
        newValidator: Validator,
        updateValueAndValidity = true,
      ): void {
        super.setValidators(newValidator);
        if (updateValueAndValidity) {
          super.updateValueAndValidity();
        }
      }

      public override setAsyncValidators(
        newValidator: AsyncValidator,
        updateValueAndValidity = true,
      ): void {
        super.setAsyncValidators(newValidator);
        if (updateValueAndValidity) {
          super.updateValueAndValidity();
        }
      }

      public validateOn(observableValidation: Observable<null | object>) {
        return validateControlOn(this, observableValidation);
      }

      public override hasError<K1 extends keyof T>(
        errorCode: ExtractStrings<E>,
        path?: [ K1 ],
      ): boolean;
      public override hasError<K1 extends keyof T, K2 extends keyof T[K1]>(
        errorCode: ExtractStrings<E>,
        path?: [ K1, K2 ],
      ): boolean;
      public override hasError<
        K1 extends keyof T,
        K2 extends keyof T[K1],
        K3 extends keyof T[K1][K2]
      >(errorCode: ExtractStrings<E>, path?: [ K1, K2, K3 ]): boolean;
      public override hasError(errorCode: ExtractStrings<E>, path?: string): boolean;
      public override hasError(errorCode: ExtractStrings<E>, path?: any): boolean {
        return super.hasError(errorCode, path);
      }

      public override setErrors(errors: Partial<E> | null, opts: EmitEvent = {}) {
        return super.setErrors(errors, opts);
      }

      public override getError<K extends keyof E, K1 extends keyof T>(
        errorCode: K,
        path?: [ K1 ],
      ): E[K] | null;
      public override getError<
        K extends keyof E,
        K1 extends keyof T,
        K2 extends keyof T[K1]
      >(errorCode: K, path?: [ K1, K2 ]): E[K] | null;
      public override getError<
        K extends keyof E,
        K1 extends keyof T,
        K2 extends keyof T[K1],
        K3 extends keyof T[K1][K2]
      >(errorCode: K, path?: [ K1, K2, K3 ]): E[K] | null;
      public override getError<K extends keyof E>(errorCode: K, path?: string): E[K] | null;
      public override getError<K extends keyof E>(errorCode: K, path?: any): E[K] | null {
        return super.getError(errorCode as any, path) as E[K] | null;
      }

      public hasErrorAndTouched<P1 extends keyof T>(
        error: ExtractStrings<E>,
        prop1?: P1,
      ): boolean;
      public hasErrorAndTouched<P1 extends keyof T, P2 extends keyof T[P1]>(
        error: ExtractStrings<E>,
        prop1?: P1,
        prop2?: P2,
      ): boolean;
      public hasErrorAndTouched<
        P1 extends keyof T,
        P2 extends keyof T[P1],
        P3 extends keyof T[P1][P2]
      >(error: ExtractStrings<E>, prop1?: P1, prop2?: P2, prop3?: P3): boolean;
      public hasErrorAndTouched<
        P1 extends keyof T,
        P2 extends keyof T[P1],
        P3 extends keyof T[P1][P2],
        P4 extends keyof T[P1][P2][P3]
      >(
        error: ExtractStrings<E>,
        prop1?: P1,
        prop2?: P2,
        prop3?: P3,
        prop4?: P4,
      ): boolean;
      public hasErrorAndTouched(error: any, ...path: any): boolean {
        return hasErrorAndTouched(this, error, ...path);
      }

      public hasErrorAndDirty<P1 extends keyof T>(
        error: ExtractStrings<E>,
        prop1?: P1,
      ): boolean;
      public hasErrorAndDirty<P1 extends keyof T, P2 extends keyof T[P1]>(
        error: ExtractStrings<E>,
        prop1?: P1,
        prop2?: P2,
      ): boolean;
      public hasErrorAndDirty<
        P1 extends keyof T,
        P2 extends keyof T[P1],
        P3 extends keyof T[P1][P2]
      >(error: ExtractStrings<E>, prop1?: P1, prop2?: P2, prop3?: P3): boolean;
      public hasErrorAndDirty<
        P1 extends keyof T,
        P2 extends keyof T[P1],
        P3 extends keyof T[P1][P2],
        P4 extends keyof T[P1][P2][P3]
      >(
        error: ExtractStrings<E>,
        prop1?: P1,
        prop2?: P2,
        prop3?: P3,
        prop4?: P4,
      ): boolean;
      public hasErrorAndDirty(error: any, ...path: any): boolean {
        return hasErrorAndDirty(this, error, ...path);
      }

      public setEnable(enable = true, opts?: ControlEventOptions) {
        enableControl(this, enable, opts);
      }

      public setDisable(disable = true, opts?: ControlEventOptions) {
        disableControl(this, disable, opts);
      }
    }

# results matching ""

# No results matching ""