Decompose monolithic readme into docs/ directory structure
This commit is contained in:
45
docs/types/properties.md
Normal file
45
docs/types/properties.md
Normal file
@@ -0,0 +1,45 @@
|
||||
[Overview](../overview.md) | [Installation](../installation.md) | [Usage](../usage.md) | **Types** | [Values](../values/) | [Syntax](../syntax/) | [TypeRegistry](../type-registry.md) | [TypeCheck](../type-check.md)
|
||||
|
||||
# Properties
|
||||
|
||||
Object properties can be modified with Readonly and Optional. The following table shows how these modifiers map between TypeScript and Json Schema.
|
||||
|
||||
```typescript
|
||||
┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐
|
||||
│ TypeBox │ TypeScript │ Json Schema │
|
||||
│ │ │ │
|
||||
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
|
||||
│ const T = Type.Object({ │ type T = { │ const T = { │
|
||||
│ name: Type.ReadonlyOptional( │ readonly name?: string │ type: 'object', │
|
||||
│ Type.String() │ } │ properties: { │
|
||||
│ ) │ │ name: { │
|
||||
│ }) │ │ type: 'string' │
|
||||
│ │ │ } │
|
||||
│ │ │ } │
|
||||
│ │ │ } │
|
||||
│ │ │ │
|
||||
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
|
||||
│ const T = Type.Object({ │ type T = { │ const T = { │
|
||||
│ name: Type.Readonly( │ readonly name: string │ type: 'object', │
|
||||
│ Type.String() │ } │ properties: { │
|
||||
│ ) │ │ name: { │
|
||||
│ }) │ │ type: 'string' │
|
||||
│ │ │ } │
|
||||
│ │ │ }, │
|
||||
│ │ │ required: ['name'] │
|
||||
│ │ │ } │
|
||||
│ │ │ │
|
||||
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
|
||||
│ const T = Type.Object({ │ type T = { │ const T = { │
|
||||
│ name: Type.Optional( │ name?: string │ type: 'object', │
|
||||
│ Type.String() │ } │ properties: { │
|
||||
│ ) │ │ name: { │
|
||||
│ }) │ │ type: 'string' │
|
||||
│ │ │ } │
|
||||
│ │ │ } │
|
||||
│ │ │ } │
|
||||
│ │ │ │
|
||||
└────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘
|
||||
```
|
||||
|
||||
Back to [Home](../../readme.md)
|
||||
Reference in New Issue
Block a user