Skip to content

Commit

Permalink
Added a note about the usage of attachPropertySignature (#2770)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti authored May 18, 2024
1 parent ff0efa0 commit 9196fff
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,7 @@ assert.deepStrictEqual(
)
```

The previous solution works perfectly and shows how we can add and remove properties to our schema at will, making it easier to consume the result within our domain model. However, it requires a lot of boilerplate. Fortunately, there is an API called `attachPropertySignature` designed specifically for this use case, which allows us to achieve the same result with much less effort:
The previous solution works perfectly and shows how we can add properties to our schema at will, making it easier to consume the result within our domain model. However, it requires a lot of boilerplate. Fortunately, there is an API called `attachPropertySignature` designed specifically for this use case, which allows us to achieve the same result with much less effort:

```ts
import { Schema } from "@effect/schema"
Expand Down Expand Up @@ -2107,6 +2107,9 @@ assert.deepStrictEqual(
)
```

> [!NOTE]
> Please note that with `attachPropertySignature`, you can only add a property, it cannot override an existing one.
### Exposed Values

You can access the members of a union schema:
Expand Down Expand Up @@ -3122,7 +3125,7 @@ Schema.required(

## Extending Schemas

The `extend` combinator allows you to add additional fields or index signatures to an existing `Schema`.
The `extend` combinator allows you to add **additional** fields or index signatures to an existing `Schema`.

Example

Expand Down

0 comments on commit 9196fff

Please sign in to comment.