-
Notifications
You must be signed in to change notification settings - Fork 808
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
ArrayClassUnique, or property-based uniqueness testing #602
Comments
Maybe something more general. E.g. |
That would work, but limiting it to objects, which currently can only be made unique through refs, makes type safety easier |
Why limiting this validator only to objects? I think it is common functionality validate array of unique strings or numbers too. Signature should be like: @ArrayUnique<T = any>(selector?: (value: T) => any)
property: T[]; And possible cases: @ArrayUnique()
property: string[] = ['hello', 'world', 'world']; // error
@ArrayUnique()
property2: number[] = [3, 3, 3, 4]; // error
@IsInstance(User, { each: true })
@ArrayUnique<User>(u => u.name)
property3: User[] = [new User('John), new User('Doe'), new User('John')]; // error |
@vlapo I made a PR. Could you please review it. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I would be picturing something like
with
Type checking is a bit overboard, and should probably be done using IsInstance, but it allowed for stronger typing inside the lambda function. If it is kept, it should probably have its own message.
The text was updated successfully, but these errors were encountered: