Don't use Object.defineProperties for creating getters and setters when you need to validate property values. It needlessly clutters the object with properties whose value is undefined.
You'll need to include a .toJSON() method to ensure that these properties are serialized properly though.
Don't use Object.defineProperties for creating getters and setters when you need to validate property values. It needlessly clutters the object with properties whose value is undefined.
You'll need to include a
.toJSON()
method to ensure that these properties are serialized properly though.