class-validator-extended - v4.2.0
    Preparing search index...

    Function SetUnique

    • Checks if the given value is a Set without duplicate values with regard to the given projection.

      // Ensure the set does not include duplicate users.
      @SetUnique<User>(user => user.id)
      administrators: Set<User>

      Type Parameters

      • Value = unknown

        The type of the set's values.

      • Projection = unknown

        The type returned by projection.

      Parameters

      • projection: (item: Value) => Projection

        The function mapping each value to the value that is used for the uniqueness check.

      • Optionaloptions: ValidationOptions

        Generic class-validator options.

      Returns PropertyDecorator