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