Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-de-saint-florent committed Apr 25, 2024
1 parent 34783fc commit 4d004bd
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,34 @@ Let's create simple User and Task schemas.

```typescript
// Schema for the Task
let taskSchema = SB.objectSchema({
name: SB.stringSchema(),
progress: SB.numberSchema(),
isCompleted: [SB.booleanSchema()],
})
let taskSchema = SB.objectSchema(
{
title: "Task",
},
{
name: SB.stringSchema(),
progress: SB.numberSchema(),
isCompleted: [SB.booleanSchema(), undefined],
},
)

// Schema for the User
let userSchema = SB.objectSchema({
id: SB.stringSchema({ pattern: "\\w" }),
firstName: SB.stringSchema(),
lastName: SB.stringSchema(),
role: SB.enumSchema(["admin", "user"]),
email: SB.stringSchema({ format: "email" }),
tags: SB.arraySchema(SB.stringSchema(), { minItems: 1 }),
age: [SB.integerSchema()],
friendsIds: [SB.arraySchema(SB.stringSchema())],
tasks: SB.arraySchema(taskSchema),
})
let userSchema = SB.objectSchema(
{
title: "User",
},
{
id: SB.stringSchema({ pattern: "\\w" }),
firstName: SB.stringSchema(),
lastName: SB.stringSchema(),
role: SB.enumSchema(["admin", "user"]),
email: SB.stringSchema({ format: "email" }),
tags: SB.arraySchema(SB.stringSchema(), { minItems: 1 }),
age: [SB.integerSchema(), undefined],
friendsIds: [SB.arraySchema(SB.stringSchema()), undefined],
tasks: SB.arraySchema(taskSchema),
},
)

// References to generated interfaces
type Task = typeof taskSchema.T
Expand Down

0 comments on commit 4d004bd

Please sign in to comment.