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

feature: Array Unqiue works with returned arrays #2137

Open
JacobBanghart opened this issue Jun 26, 2023 · 0 comments · May be fixed by #2138
Open

feature: Array Unqiue works with returned arrays #2137

JacobBanghart opened this issue Jun 26, 2023 · 0 comments · May be fixed by #2138
Labels
flag: needs discussion Issues which needs discussion before implementation. type: feature Issues related to new features.

Comments

@JacobBanghart
Copy link

JacobBanghart commented Jun 26, 2023

Description

I have a situation where I want to validate that v2 is unique across all v's. I wrote a decorator to handle this and was pointed over here for similar functionality but was unable to do what I was trying to accomplish.

interface V{
    v2: {id: string}[]
}

class VValidate{
    @ArrayUnique(v => v.v2.flatMap(item => item.id))
    v: V[]
}

Proposed solution

Adjust arrayUnique to use flatMap rather than map. This should only change its interaction with arrays.
Problem: Arrays that were to match based on reference would now be destructed into their components and I am unsure about the usage of this.
Alternative: Create a new decorator for this but it seems like overkill for this use case

@JacobBanghart JacobBanghart added flag: needs discussion Issues which needs discussion before implementation. type: feature Issues related to new features. labels Jun 26, 2023
@JacobBanghart JacobBanghart linked a pull request Jun 26, 2023 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag: needs discussion Issues which needs discussion before implementation. type: feature Issues related to new features.
Development

Successfully merging a pull request may close this issue.

1 participant