@tsed/schema
Usage
typescript
import { Email } from "@tsed/schema";
See /packages/specs/schema/src/types/decorators/common/format.ts.
Overview
ts
const Email: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<() => import("../../utils/withErrorMsg.js").ErrorChainedMethods<(format: JsonFormatTypes | ValueOf<JsonFormatTypes>) => (...args: any[]) => any>>;
Description
Apply an email validation on property.
WARNING
For v6 user, use Email from @tsed/schema instead of @tsed/platform-http.
Example
With primitive type
typescript
class Model {
@Email()
property: string;
}
Will produce:
json
{
"type": "object",
"properties": {
"property": {
"type": "string",
"format": "email"
}
}
}
With array type
typescript
class Model {
@Email()
@CollectionOf(String)
property: string[];
}
Will produce:
json
{
"type": "object",
"properties": {
"property": {
"type": "array",
"items": {
"type": "string",
"format": "email"
}
}
}
}