<div align='center'>
<h1>TypeBox</h1>
<p>JSON Schema Type Builder with Static Type Resolution for TypeScript</p>
<img src="https://github.com/sinclairzx81/typebox/blob/master/typebox.png?raw=true" />
<br />
<br />
[![npm version](https://badge.fury.io/js/%40sinclair%2Ftypebox.svg)](https://badge.fury.io/js/%40sinclair%2Ftypebox)
[![Downloads](https://img.shields.io/npm/dm/%40sinclair%2Ftypebox.svg)](https://www.npmjs.com/package/%40sinclair%2Ftypebox)
[![GitHub CI](https://github.com/sinclairzx81/typebox/workflows/GitHub%20CI/badge.svg)](https://github.com/sinclairzx81/typebox/actions)
</div>
<a name="Install"></a>
## Install
#### Npm
```bash
$ npm install @sinclair/typebox --save
```
#### Deno
```typescript
import { Static, Type } from 'npm:@sinclair/typebox'
```
#### Esm
```typescript
import { Static, Type } from 'https://esm.sh/@sinclair/typebox'
```
## Example
```typescript
import { Static, Type } from '@sinclair/typebox'
const T = Type.Object({ // const T = {
x: Type.Number(), // type: 'object',
y: Type.Number(), // required: ['x', 'y', 'z'],
z: Type.Number() // properties: {
}) // x: { type: 'number' },
// y: { type: 'number' },
// z: { type: 'number' }
// }
// }
type T = Static<typeof T> // type T = {
// x: number,
// y: number,
// z: number
// }
```
<a name="Overview"></a>
## Overview
TypeBox is a runtime type builder that creates in-memory JSON Schema objects that can be statically inferred as TypeScript types. The schemas produced by this library are designed to match the static type assertion rules of the TypeScript compiler. TypeBox enables one to create a unified type that can be statically checked by TypeScript and runtime asserted using standard JSON Schema validation.
This library is designed to enable JSON schema to compose with the same flexibility as TypeScript's type system. It can be used as a simple tool to build up complex schemas or integrated into REST or RPC services to help validate data received over the wire.
License MIT
## Contents
- [Install](#install)
- [Overview](#overview)
- [Usage](#usage)
- [Types](#types)
- [Standard](#types-standard)
- [Extended](#types-extended)
- [Modifiers](#types-modifiers)
- [Options](#types-options)
- [Generics](#types-generics)
- [References](#types-references)
- [Recursive](#types-recursive)
- [Conditional](#types-conditional)
- [Template Literal](#types-template-literal)
- [Guards](#types-guards)
- [Unsafe](#types-unsafe)
- [Strict](#types-strict)
- [Values](#values)
- [Create](#values-create)
- [Clone](#values-clone)
- [Check](#values-check)
- [Convert](#values-convert)
- [Cast](#values-cast)
- [Equal](#values-equal)
- [Hash](#values-hash)
- [Diff](#values-diff)
- [Patch](#values-patch)
- [Errors](#values-errors)
- [Mutate](#values-mutate)
- [Pointer](#values-pointer)
- [TypeCheck](#typecheck)
- [Ajv](#typecheck-ajv)
- [TypeCompiler](#typecheck-typecompiler)
- [TypeSystem](#typesystem)
- [Types](#typesystem-types)
- [Formats](#typesystem-formats)
- [Policies](#typesystem-policies)
- [Benchmark](#benchmark)
- [Compile](#benchmark-compile)
- [Validate](#benchmark-validate)
- [Compression](#benchmark-compression)
- [Contribute](#contribute)
<a name="usage"></a>
## Usage
The following shows general usage.
```typescript
import { Static, Type } from '@sinclair/typebox'
//--------------------------------------------------------------------------------------------
//
// Let's say you have the following type ...
//
//--------------------------------------------------------------------------------------------
type T = {
id: string,
name: string,
timestamp: number
}
//--------------------------------------------------------------------------------------------
//
// ... you can express this type in the following way.
//
//--------------------------------------------------------------------------------------------
const T = Type.Object({ // const T = {
id: Type.String(), // type: 'object',
name: Type.String(), // properties: {
timestamp: Type.Integer() // id: {
}) // type: 'string'
// },
// name: {
// type: 'string'
// },
// timestamp: {
// type: 'integer'
// }
// },
// required: [
// 'id',
// 'name',
// 'timestamp'
// ]
// }
//--------------------------------------------------------------------------------------------
//
// ... then infer back to the original static type this way.
//
//--------------------------------------------------------------------------------------------
type T = Static<typeof T> // type T = {
// id: string,
// name: string,
// timestamp: number
// }
//--------------------------------------------------------------------------------------------
//
// ... then use the type both as JSON schema and as a TypeScript type.
//
//--------------------------------------------------------------------------------------------
import { Value } from '@sinclair/typebox/value'
function receive(value: T) { // ... as a Static Type
if(Value.Check(T, value)) { // ... as a JSON Schema
// ok...
}
}
```
<a name='types'></a>
## Types
TypeBox types are JSON schema fragments that can be composed into more complex types. Each fragment is structured such that a JSON schema compliant validator can runtime assert a value the same way TypeScript will statically assert a type. TypeBox provides a set of Standard types which are used create JSON schema compliant schematics as well as an Extended type set used to create schematics for constructs native to JavaScript.
<a name='types-standard'></a>
### Standard Types
The following table lists the Standard TypeBox types. These types are fully compatible with the JSON Schema Draft 6 specification.
```typescript
┌────────────────────────────────┬─────────
没有合适的资源?快使用搜索试试~ 我知道了~
vue3+pinia+element-plus搭建的模板工程
共2001个文件
md:1038个
js:791个
json:165个
需积分: 0 7 下载量 112 浏览量
2024-01-04
15:28:00
上传
评论 1
收藏 63.53MB ZIP 举报
温馨提示
这里有一个基于最新技术栈构建的系统模板工程,结合了Pinia、Vue3、Element Plus和Webpack 5的强大力量。它为您提供了一个前所未有的开发体验,让您的项目脱颖而出。 这个模板工程不仅仅是一个简单的骨架,它还内置了四种令人惊叹的布局方式:默认布局、经典布局、双栏布局和单栏布局。无论您是追求时尚现代感还是传统经典风格,都能找到最适合您项目需求的布局风格。 更加令人兴奋的是,这个模板工程已经事先为您配置了暗黑模式。这意味着您的应用程序可以轻松地根据用户偏好切换到黑暗主题,为用户带来更加炫酷和舒适的界面体验。 而且,这个模板工程对全局配置进行了高度拆分和封装。通过清晰的架构和优雅的代码,您可以轻松地管理和定制全局配置,节省宝贵的开发时间,让您专注于构建出色的功能和用户体验。 无论您是一名经验丰富的开发者还是刚入门的新手,这个Pinia+Vue3+Element Plus+Webpack 5搭建的系统模板工程都将成为您的得力助手。 此zip解压后即可立即运行,为了保证项目依赖一致性,我将node_modules也一起上传了~
资源推荐
资源详情
资源评论
收起资源包目录
vue3+pinia+element-plus搭建的模板工程 (2001个子文件)
.DS_Store 6KB
vue.global.js 463KB
vue.esm-browser.js 435KB
vue.runtime.global.js 321KB
vue.runtime.esm-browser.js 297KB
vue-router.global.js 154KB
vue-router.esm-browser.js 141KB
vue.esm-browser.prod.js 131KB
vue.global.prod.js 128KB
js-yaml.js 112KB
typebox.js 97KB
volume.js 90KB
vue.runtime.esm-browser.prod.js 84KB
vue.runtime.global.prod.js 83KB
command.js 61KB
BigInteger.js 51KB
loader.js 46KB
index.js 43KB
configuration.js 40KB
floating-ui.core.umd.js 39KB
js-yaml.min.js 39KB
emit.js 36KB
emit.js 36KB
_stream_readable.js 35KB
regenerate.js 34KB
errors.js 34KB
floating-ui.core.esm.js 33KB
dumper.js 31KB
tokenize.js 30KB
grid-utils.js 29KB
response.js 27KB
parse.js 27KB
floating-ui.dom.umd.js 27KB
compiler.js 26KB
estraverse.js 26KB
vue-router.global.prod.js 24KB
utils.js 24KB
prefixes.js 23KB
_stream_writable.js 21KB
break-up.js 21KB
processor.js 21KB
BigInteger.min.js 21KB
bigfraction.js 21KB
fraction.js 20KB
index.js 20KB
resolver_sync.js 20KB
DirectoryWatcher.js 20KB
index.iife.js 20KB
floating-ui.dom.esm.js 20KB
resolver.js 19KB
check.js 19KB
cast.js 18KB
style.js 18KB
create.js 17KB
node.js 17KB
conversions.js 17KB
index.js 17KB
convert.js 16KB
List.js 15KB
index.js 15KB
override-properties.js 14KB
application.js 14KB
parser.js 14KB
hybi.js 14KB
merge-into-shorthands.js 14KB
best-practices.js 14KB
pluginWebpack5.js 13KB
lazy-result.js 13KB
read-sources.js 13KB
prefixes.js 13KB
index.js 13KB
restructure.js 12KB
errors.js 12KB
request.js 12KB
visit.js 12KB
validator.js 12KB
imports.js 12KB
help.js 12KB
floating-ui.core.umd.min.js 12KB
browser-global.js 11KB
index.js 11KB
async.js 11KB
can-override.js 11KB
visit.js 11KB
index.js 11KB
gradient.js 10KB
pluginWebpack4.js 10KB
container.js 10KB
watchpack.js 10KB
mock.js 10KB
picomatch.js 10KB
optimize.js 10KB
index.js 10KB
restore.js 10KB
index.js 9KB
floating-ui.dom.umd.min.js 9KB
scan.js 9KB
map-generator.js 9KB
tidy-rules.js 9KB
node.js 9KB
共 2001 条
- 1
- 2
- 3
- 4
- 5
- 6
- 21
资源评论
你吃香蕉吗?
- 粉丝: 574
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功