Releases: sylvainpolletvillard/ObjectModel
Releases · sylvainpolletvillard/ObjectModel
v3.2
- ObjectModel instances enumerated keys behaviour has been changed to not include optional properties that are defined in the model definition but not assigned on the instance. This is required to resolve some issues with some external libraries integration.
v3.1
- sealed models now prevent all undeclared properties at initial or future assignments, on direct and nested properties
- add a params argument to object models constructor, i.e.
Model(definition, { sealed: true })
- add a dedicated section in the docs for sealed models
- bugfix: assignments with null-safe traversal
v3.0
New features in v3
- ES6 Proxies are used everywhere instead of ES5 property getters
- New models: Map models and Set models
- A custom devtool formatter in Chrome
sealed
mode for object models to prevent undeclared properties- usable as ES Module:
import { ObjectModel } from "objectmodel"
to enable tree shaking
Breaking changes in v3
- since v3 relies on ES6 Proxies, it is only usable on modern browsers: Edge 14+ / Firefox 47+ / Chrome 50+ / Node 6+
- All the possible operations on objects, including special ones like
delete
,defineProperty
orObject.keys
, are now checked against the model definition. Consequently, new type errors could be found after upgrading. Model.conventionForPrivate
andModel.conventionForConstant
have been moved toModel.prototype
so that you can change these conventions specifically by model- Private properties are now private for real: you cannot use them outside of the model's own methods
Notes
This is almost a full rewrite of the library that I have been working on for over a year. ObjectModel is now written in ES6, has solid unit testing with over 400 assertions, and overall has much better mechanics to validate and cast your models. Enjoy !
v2.6
- Basic, Object and Array model constructors now throws an error if no definition is provided
- All the type errors now includes
path
information and have the same properties
v2.5
v2.4
NaN
andInvalid Date
are now considered invalid for typesNumber
andDate
- function models instances called with invalid arguments are no longer executed
- added
model.defaultTo
v2.3
- assertions now use try/catch to catch exceptions. When an exception is catched, the assertion fails and the exception is passed to the error collector
- TypeError messages have been improved, especially for assertion failures. It now indicates the value tested and what the assertion returned.
v2.2
When constructing a composed object model, properties are automatically casted to model instances according to the definition. Now, this also works for union types. If several models are suitable within a union type, there is an ambiguity and the object will be left untouched with a warning console message.
See #24 for details
v2.1
- assertions are now inherited from
Model.prototype
, which enables you to add global assertions - assertions now require to return
true
to validate. Truthy values do not pass anymore - assertions error messages can now be functions called with the assertion result as argument
v2.0.1
- better model string formatting
- fixed custom error collector inheritance in extended models