From 9196fff545f4ca97ffdb038c66d26a14176d7064 Mon Sep 17 00:00:00 2001 From: Giulio Canti Date: Sat, 18 May 2024 07:35:44 +0200 Subject: [PATCH] Added a note about the usage of attachPropertySignature (#2770) --- packages/schema/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/schema/README.md b/packages/schema/README.md index 850eb4ff1f..815fbbcd57 100644 --- a/packages/schema/README.md +++ b/packages/schema/README.md @@ -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" @@ -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: @@ -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