ampersand-state
Advanced tools
Comparing version 4.8.0 to 4.8.1
@@ -194,2 +194,3 @@ 'use strict'; | ||
// If we have a defined type and the new type doesn't match, and we are not null, throw error. | ||
// If we require specific value and new one is not one of them, throw error (unless it has default value or we're unsetting it with undefined). | ||
@@ -206,3 +207,8 @@ if (newVal === undefined && def.required) { | ||
if (def.values && !includes(def.values, newVal)) { | ||
throw new TypeError('Property \'' + attr + '\' must be one of values: ' + def.values.join(', ') + '. Tried to set ' + newVal); | ||
var defaultValue = result(def, 'default'); | ||
if (unset && defaultValue !== undefined) { | ||
newVal = defaultValue; | ||
} else if (!unset || (unset && newVal !== undefined)) { | ||
throw new TypeError('Property \'' + attr + '\' must be one of values: ' + def.values.join(', ') + '. Tried to set ' + newVal); | ||
} | ||
} | ||
@@ -620,3 +626,3 @@ | ||
set: function () { | ||
throw new TypeError('"' + name + '" is a derived property, it can\'t be set directly.'); | ||
throw new TypeError("`" + name + "` is a derived property, it can't be set directly."); | ||
} | ||
@@ -623,0 +629,0 @@ }); |
{ | ||
"name": "ampersand-state", | ||
"description": "An observable, extensible state object with derived watchable properties.", | ||
"version": "4.8.0", | ||
"version": "4.8.1", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -6,0 +6,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62714
733