# Default Decorator validation swagger schema

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

# Overview

function Default(defaultValue: string | number | boolean | {}): (...parameters: any[]) => any;

# Description

There are no restrictions placed on the value of this keyword.

WARNING

This decorator will be removed in v7. For v6 user, use from @tsed/schema instead of @tsed/common.

This keyword can be used to supply a default JSON value associated with a particular schema. It is RECOMMENDED that a default value be valid against the associated schema.

# Example

class Model {
   @Default("10")
   property: string = "10";
}
1
2
3
4

Will produce:

{
  "type": "object",
  "properties": {
    "property": {
      "type": "string",
      "default": "10"
    }
  }
}
1
2
3
4
5
6
7
8
9