Skip to content

Commit

Permalink
Merge pull request #6 from kevbaldwyn/2.1
Browse files Browse the repository at this point in the history
feat: make all properties of all value objects instantiated with ValueObject readonly
  • Loading branch information
kevbaldwyn committed Jan 10, 2021
2 parents 7f49556 + 87c0fa3 commit d2fb11b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/CompositeValueObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ export type CompositeProperties = Record<string, ValueObject<unknown>>;
export class CompositeValueObject<
T extends CompositeProperties
> extends ValueObject<T> {
constructor(args: T) {
super(Object.freeze(args));
}

public isSame = (object: ValueObject<CompositeProperties>): boolean => {
return ObjectUtils.isObjectEqual(
this.toNative(),
Expand Down
3 changes: 3 additions & 0 deletions src/ValueObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export abstract class ValueObject<V> implements ValueObjectInterface<V> {

constructor(value: V) {
this.value = value;
if (typeof this.value === "object") {
Object.freeze(this.value);
}
}

abstract isSame(object: ValueObjectInterface<V>): boolean;
Expand Down

0 comments on commit d2fb11b

Please sign in to comment.