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

Support the full FormControl API #38

Closed
gparlakov opened this issue Nov 19, 2020 · 4 comments
Closed

Support the full FormControl API #38

gparlakov opened this issue Nov 19, 2020 · 4 comments

Comments

@gparlakov
Copy link
Owner

Support the AbstractFormControlOptions:

     validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, 
     asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null
@gparlakov
Copy link
Owner Author

Add the types of the emissions

 * Type encapsulating the Angular Form options:
 * `emitEvent` - do we emit event;
 * `onlySelf` - do we bubble up to parent
 * `emitModelToViewChange` - When true or not supplied (the default), each change triggers an onChange event to update the view.
 * `emitViewToModelChange` - When true or not supplied (the default), each change triggers an ngModelChange event to update the model.
 */
export interface FormEventOptions {
    emitEvent?: boolean;
    onlySelf?: boolean;
    emitModelToViewChange?: boolean;
    emitViewToModelChange?: boolean;
}

@Mongole666
Copy link

Mongole666 commented Jun 21, 2021

Handing ValidatorFn[] and AsyncValidatorFn[] seems to be done by just adding these to the constructor call in the types. Or am I missing something here? So can this issue be closed with a new minor version in the near future? @gparlakov

@gparlakov
Copy link
Owner Author

gparlakov commented Jul 7, 2021

@Mongole666 yes - you are correct, I just saw that the typedFormControl does not support that while typedFormGroup and typedFormArray do... Will definitely do a minor release with that, thanks.

In the mean time Validators.compose and Validators.composeAsync can do the trick...

const form = typedFormControl<number>(1, Validators.compose([Validators.required, Validators.minLength(1)]), Validators.composeAsync([....]))

@gparlakov
Copy link
Owner Author

@Mongole666 just released version 1.1.2 with support for that

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

2 participants