# PropertyType Decorator
Module | import { PropertyType } from "@tsed/common" |
---|---|
Source | /packages/common/src/jsonschema/decorators/propertyType.ts |
# Overview
function PropertyType(type: Type<any>): Function;
# Description
Set the type of the array items. The possible value is String, Boolean, Number, Date, Object, Class, etc...
TIP
This decorator is used by the Converters to deserialize correctly your model.
class Model {
@PropertyType(String)
property: string[];
}
1
2
3
4
2
3
4
WARNING
You didn't use the type Type = string | number
as parameters Type.
Didn't works:
type Type = "string" | "number"
class Model {
@PropertyType(Type)
property: Type[];
}
1
2
3
4
5
2
3
4
5
Works with converter and AJV:
type Type = "string" | "number"
class Model {
@Property()
@AllowTypes("string", "number") // for AJV
property: Type[];
}
1
2
3
4
5
6
2
3
4
5
6
:::