You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[14. Available resources](#14-avaliable-resourses)
87
-
88
-
> This package provide utils file and interfaces to assistant build a complex application with domain driving design and typescript
71
+
---
89
72
90
73
## 1. Ubiquitous language:
91
74
@@ -185,3 +168,190 @@ Check lib documentation on link [Here](https://github.com/4lessandrodev/types-dd
185
168
- Used to translate models from outside systems or legacy apps to models inside the bounded context and vice versa, and also to ease the communication with legacy services
186
169
- Can use service facades and model adapters
187
170
171
+
172
+
173
+
---
174
+
175
+
## 13 - Summary - Basic Usage
176
+
177
+
Check full documentation on link [Here](https://github.com/4lessandrodev/types-ddd/tree/main/docs)
178
+
179
+
### Value Object
180
+
181
+
> A value object is a small, simple object that represents a single value or characteristic, such as a monetary amount or a date. It is characterized by having no identity of its own, meaning it is equal to another value object if its values are equal, regardless of its reference. Value objects are often used in domain-driven design to represent simple entities in the system.
182
+
183
+
#### Create a value object with business rules.
184
+
185
+
```ts
186
+
187
+
import { ValueObject, Ok, Fail, Result } from'types-ddd';
if(!isValid) returnFail("Invalid amount for money");
233
+
234
+
returnOk(newMoney({ amount }));
235
+
}
236
+
}
237
+
238
+
```
239
+
240
+
How to use value object instance
241
+
242
+
```ts
243
+
244
+
// operation result
245
+
const result =Money.create(500);
246
+
247
+
// check if provided a valid value
248
+
console.log(result.isOk());
249
+
250
+
>true
251
+
252
+
// money instance
253
+
const money =result.value();
254
+
255
+
money.get("amount"); // 500
256
+
257
+
```
258
+
259
+
---
260
+
261
+
### Entity
262
+
263
+
> An entity in domain-driven design is an object that represents a concept in the real world and has a unique identity and attributes. It is a fundamental building block used to model complex business domains.
0 commit comments