class-validator-extended
Version:
Additional validators for class-validator.
22 lines (21 loc) • 932 B
TypeScript
import type { ValidationOptions } from 'class-validator';
/** @hidden */
export declare const SET_UNIQUE = "setUnique";
/**
* Checks if the given value is a [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
* without duplicate values with regard to the given projection.
*
* #### Example
* ```typescript
* // Ensure the set does not include duplicate users.
* @SetUnique<User>(user => user.id)
* administrators: Set<User>
* ```
*
* @category Set
* @param projection The function mapping each value to the value that is used for the uniqueness check.
* @param options Generic class-validator options.
* @typeParam Value The type of the set's values.
* @typeParam Projection The type returned by `projection`.
*/
export declare function SetUnique<Value = unknown, Projection = unknown>(projection: (item: Value) => Projection, options?: ValidationOptions): PropertyDecorator;