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

[Proposal] Tuple type #1395

Closed
SevenOutman opened this issue Jun 17, 2021 · 5 comments
Closed

[Proposal] Tuple type #1395

SevenOutman opened this issue Jun 17, 2021 · 5 comments

Comments

@SevenOutman
Copy link

The problem

It's a common case that we use arrays not with repeating items but tuples. It's difficult to validate these tuples with existing yup.array().of() API.

Example case

Say I'm using a dateRange field with type [Date, Date] tuple - a starting date and an ending date.

const schema = yup.object({
  dateRange: yup.array()
    .of(yup.date())
})

Now I want to apply different validation rules for starting date and ending date, and, I want the validation errors (if any) to be assigned to the dateRange field all the same, no matter it comes from starting date or ending date. There's no good way to achieve with existing APIs.

The proposal

A new yup.tuple() type for validating tuples.

const schema = yup.object({
  dateRange: yup.tuple([
    yup.date().startingDateRule(),
    yup.date().endingDateRule()
  ])
})
@filose
Copy link

filose commented Jan 14, 2022

Hi, just wondering if there was any update on this proposal? Can see the feature has been added in this WIP PR #1546 which has updated the docs but doesn't look like the package has been released since then?

@filose
Copy link

filose commented Jan 14, 2022

Ah sorry have just seen this https://github.com/jquense/yup/blob/master/README.md?plain=1#L5 ignore me 🙃

@jquense jquense closed this as completed Jan 14, 2022
@filose
Copy link

filose commented Jan 21, 2022

Hi @jquense, although the WIP PR I reference earlier was merged (and the docs updated) tuple support is not available in the latest v1 beta release. Do you have any estimate for when it might be released? Thanks in advance

@jquense
Copy link
Owner

jquense commented Jan 21, 2022

just released beta.2

@filose
Copy link

filose commented Jan 24, 2022

Yeeeeehaw! Many thanks 🙏

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

3 participants