A generic set of Typescript Value Objects for use in any project.
A work in progress, please check back soon
When people exchange business cards, they generally do not distinguish between each unique card; they only are concerned about the information printed on the card. In this context, business cards are value objects.
Not published to NPM yet!
To make this code consistent, we've stuck to a certain set of restrictions:
- Must be immutable
- Must contain one value
- Can instantiate new object from value
- Can be created from multiple arguments
- Can be equal regardless of object
- Must have a zero lifespan
Disclaimer: This is my interpretation of "The rules".
The value object's value must be set at the time of construction. At no point should the value be mutated within the object.
The value object can only be constructed from one value, this can be any of the following types:
- boolean
- integer
- float/double
- string
- array
- object
- resource
- null
Rather than mutating, a new object can be instantiated from an existing one.
More documentation will follow...