Строковый тип.
new Context((types) => ({
short: types.string,
callable: types.string(),
callableOptions: types.string()({ title: "title" }),
callableDefault: types.string("default"),
optional: types.string.optional(),
optionalOptions: types.string.optional()({ title: "title" }),
optionalDefault: types.string.optional("default"),
required: types.string.required("default"),
requiredOptions: types.string.required("default")({ title: "title" }),
requiredDefault: types.string.required("default"),
}))
Числовой тип.
new Context((types) => ({
number: types.number,
callable: types.number(),
callableOptions: types.number()({ title: "number" }),
callableDefault: types.number(4),
optional: types.number.optional(),
optionalOptions: types.number.optional()({ title: "number" }),
optionalDefault: types.number.optional(4),
required: types.number.required(4),
requiredOptions: types.number.required(4)({ title: "number" }),
}))
Логический тип.
new Context((types) => ({
short: types.boolean,
callable: types.boolean(),
callableOptions: types.boolean()({ title: "boolean" }),
callableDefault: types.boolean(true),
optional: types.boolean.optional(),
optionalOptions: types.boolean.optional()({ title: "boolean" }),
optionalDefault: types.boolean.optional(true),
required: types.boolean.required(true),
requiredOptions: types.boolean.required(true)({ title: "boolean" }),
}))
Массив примитивов. Массив плоский и однородный.
new Context(
(types) => ({
short: types.array,
callable: types.array(),
callableOptions: types.array()({ title: "array" }),
callableDefault: types.array([1, 2, 3]),
optional: types.array.optional(),
optionalOptions: types.array.optional()({ title: "array" }),
optionalDefault: types.array.optional([1, 2, 3]),
required: types.array.required([1, 2, 3]),
requiredOptions: types.array.required([1, 2, 3])({ title: "array" }),
})
Перечисления.
Перечисления однородные.
Значения для enum могут отсутствовать. (схема)
new Context((types) => ({
short: types.enum,
callable: types.enum(),
optional: types.enum().optional(),
}))
Варианты декларации.
new Context((types) => ({
short: types.enum,
callable: types.enum(),
callableOptions: types.enum(1, 2)()({ title: "enum" }),
callableDefault: types.enum("user", "admin")("user"),
optional: types.enum().optional(),
optionalOptions: types.enum().optional()({ title: "enum" }),
optionalDefault: types.enum("user", "admin").optional("user"),
required: types.enum("user", "admin").required("user"),
requiredOptions: types.enum(1, 2, 3, 4).required(4)({ title: "числовые значения" }),
})
Типы для описания контекста.
Является фабрикой для создания схемы контекста.
Ограничения
Опциональный
Опциональные поля могут принимать значения
null
.Имеет возможность определения в 3 вариантах:
Обязательный
Значение по умолчанию
Поддерживается возможность передачи значения по умолчанию для опционального и обязательного поля.
В опциональном поле
В обязательном поле
Без значения по умолчанию в обязательном поле
Обязательное поле должно иметь значение по умолчанию.
Метаданные
Заголовок