Skip to content

Instantly share code, notes, and snippets.

@ddamko
Last active October 11, 2016 19:20
Show Gist options
  • Save ddamko/a6d963e28b863404ff0feec5939f81df to your computer and use it in GitHub Desktop.
Save ddamko/a6d963e28b863404ff0feec5939f81df to your computer and use it in GitHub Desktop.
Trying to create a base Value Object class in TypeScript.
const VO = require('value-object-js');
abstract class ValueObject {
constructor(private name: string, private value: any) {
const ValueObj = VO.define(name ,{
validate: (value) => { return value }
});
return new ValueObj(value);
}
}
class Money extends ValueObject {
constructor(value: number) {
super('Money', value);
}
}
let money_one = new Money(3);
let money_two = new Money(3);
console.log(money_one === money_two); // => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment