# UniqueItems Decorator

Module
import { UniqueItems } from "@tsed/common"
Source/packages/common/src/jsonschema/decorators/uniqueItems.ts

# Overview

function UniqueItems(uniqueItems?: boolean): (...parameters: any[]) => any;

# Description

If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.

# Example

class Model {
   @UniqueItems()  // default true
   property: number[];
}
1
2
3
4
class Model {
   @PropertyType(String)
   @UniqueItems()
   property: string[];
}
1
2
3
4
5

Will produce:

{
  "type": "object",
  "properties": {
    "property": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string"
      }
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12