digitallinguistics / javascript

A JavaScript library for working with linguistic data in DLx format
https://developer.digitallinguistics.io/javascript
MIT License
2 stars 0 forks source link

use normal getters and setters for property validation #139

Closed dwhieb closed 4 years ago

dwhieb commented 4 years ago

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.

dwhieb commented 4 years ago

Getters and setters make the properties non-enumerable by default, which is highly undesirable behavior.