Skip to content

TimeFormat

@tsed/schema

Usage

typescript
import { TimeFormat } from "@tsed/schema";

See /packages/specs/schema/src/types/decorators/common/format.ts.

Overview

ts
const TimeFormat: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<() => import("../../utils/withErrorMsg.js").ErrorChainedMethods<(format: JsonFormatTypes | ValueOf<JsonFormatTypes>) => (...args: any[]) => any>>;

Description

Apply a time validation on property.

Example

With primitive type

typescript
class Model {
   @TimeFormat()
   property: string;
}

Will produce:

json
{
  "type": "object",
  "properties": {
    "property": {
      "type": "string",
      "format": "time"
    }
  }
}

With array type

typescript
class Model {
   @TimeFormat()
   @CollectionOf(String)
   property: string[];
}

Will produce:

json
{
  "type": "object",
  "properties": {
    "property": {
      "type": "array",
      "items": {
         "type": "string",
         "format": "time"
      }
    }
  }
}

Released under the MIT License.