Skip to content

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
4lessandrodev committed Nov 28, 2024
1 parent eb9790d commit 12ffca9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@ export default class Money extends ValueObject<Props> {

return Ok(new Money({ amount }));
}

// try initialize an instance. throw erro if provide an invalid value
public static init(amount: number): Money {

const isValid = this.isValidProps({ amount });
if(!isValid) throw new Error("Invalid amount for money");

return new Money({ amount });
}
}

```
Expand Down Expand Up @@ -377,6 +386,10 @@ export default class Payment extends Entity<Props> {
public static create(props: Props): Result<Payment> {
return Ok(new Payment(props));
}

public static init(props: Props): Payment {
return new Payment(props);
}
}

```
Expand Down Expand Up @@ -513,6 +526,10 @@ export default class Order extends Aggregate<Props> {
public static create(props: Props): Result<Order> {
return Ok(new Order(props));
}

public static init(props: Props): Order {
return new Order(props);
}
}

```
Expand Down

0 comments on commit 12ffca9

Please sign in to comment.