Skip to content

Control Validators should be observable chains #9119

@escardin

Description

@escardin
  • I'm submitting a ...
  • feature request

Current behavior
Validators are callback functions

Expected/desired behavior
Validators should be observables.

  • What is the motivation / use case for changing the behavior?

Currently it is very counter intuitive to build debounced async validators (http://plnkr.co/edit/2NuNj1lBj2e6OdUJjFra?p=preview). It would be much cleaner to work with an observable chain that is subscribed once, instead of subscribed for every value change of a control.

It could look like this:

new Control('',validator$=>{
    return validator$.map(valid=>{
        valid.errors.minLen=valid.value.length>5?null,"Length must be at least 5";
        return valid;
    });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions