Skip to content

Releases: sylvainpolletvillard/ObjectModel

v3.2

08 Nov 14:49
Compare
Choose a tag to compare
  • 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

15 Jul 16:51
Compare
Choose a tag to compare
  • 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

29 Jun 18:11
Compare
Choose a tag to compare

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 or Object.keys, are now checked against the model definition. Consequently, new type errors could be found after upgrading.
  • Model.conventionForPrivate and Model.conventionForConstant have been moved to Model.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

17 Jan 20:37
Compare
Choose a tag to compare
  • 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

02 Nov 21:08
Compare
Choose a tag to compare
  • array models elements are now automatically casted to their suitable model if found
  • function models arguments and return values are now automatically casted to their suitable model if found
  • added support for yarn

v2.4

25 Sep 14:24
Compare
Choose a tag to compare
  • NaN and Invalid Date are now considered invalid for types Number and Date
  • function models instances called with invalid arguments are no longer executed
  • added model.defaultTo

v2.3

04 Sep 18:55
Compare
Choose a tag to compare
  • 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

02 Sep 22:11
Compare
Choose a tag to compare

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

12 Jul 19:25
Compare
Choose a tag to compare
  • 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

10 Jul 13:55
Compare
Choose a tag to compare
  • better model string formatting
  • fixed custom error collector inheritance in extended models