Skip to content

Use the rest operator in Validators.compose #7432

Closed

Description

@jnizet
  • I'm submitting a feature request
  • What is the current behavior?

To compose several validators, we must pass an array of functions to Validators.compose. For example:

Validators.compose([Validators.required, Register.validYear, Register.validBirthYear])
  • What is the expected behavior?

It would be more natural to not have to wrap the arguments into an array, and simply pass all the validators. For example:

 Validators.compose(Validators.required, Register.validYear, Register.validBirthYear)

The change that would allow this is to change the declaration of the compose() function from

static compose(validators: Function[]): Function;

to

static compose(...validators: Function[]): Function;
  • What is the motivation / use case for changing the behavior?

It's not a big thing, of course, but it would make the API more pleasant to use.

  • Please tell us about your environment:
  • Angular version: 2.0.0-beta.7
  • Browser: [all]
  • Language: [TypeScript X.X | ES6/7]

Activity

  1. added
    feature
    on Sep 1, 2016
  2. added this to the Backlog milestone on Jan 23, 2018
  3. angular-robot commented on May 21, 2021

    @angular-robot
    Contributor

    Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

    Find more details about Angular's feature request process in our documentation.

  4. angular-robot commented on Jun 10, 2021

    @angular-robot
    Contributor

    Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

    We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

    You can find more details about the feature request process in our documentation.

  5. angular-automatic-lock-bot commented on Jul 11, 2021

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  6. locked and limited conversation to collaborators on Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: formsfeaturefreq2: medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions