immutable-class
Advanced tools
Comparing version 0.9.10 to 0.10.0
@@ -47,2 +47,7 @@ "use strict"; | ||
} | ||
if (property.type === exports.PropertyType.ARRAY) { | ||
if (!Array.isArray(pv)) { | ||
throw new Error(this.constructor.name + "." + propertyName + " must be an Array"); | ||
} | ||
} | ||
var validate = property.validate; | ||
@@ -49,0 +54,0 @@ if (validate) { |
@@ -203,2 +203,17 @@ "use strict"; | ||
}); | ||
it('should validate array values when PropertyType is set', function () { | ||
expect(function () { | ||
return car_mock_1.Car.fromJS({ | ||
fuel: 'electric', | ||
name: 'ford', | ||
passengers: 'badString', | ||
}); | ||
}).toThrow('Car.passengers must be an Array'); | ||
}); | ||
it('should set PropertyType.ARRAY to empty array if not defined', function () { | ||
expect(car_mock_1.Car.fromJS({ | ||
fuel: 'electric', | ||
name: 'ford', | ||
})).toEqual({ fuel: 'electric', name: 'ford', passengers: [] }); | ||
}); | ||
}); |
@@ -23,2 +23,3 @@ import { BackCompat, BaseImmutable, Property } from './base-immutable'; | ||
driver?: Driver; | ||
passengers?: string[]; | ||
} | ||
@@ -34,2 +35,3 @@ export interface CarJS { | ||
driver?: DriverJS; | ||
passengers?: string[]; | ||
} | ||
@@ -36,0 +38,0 @@ export declare class Car extends BaseImmutable<CarValue, CarJS> { |
@@ -101,2 +101,6 @@ "use strict"; | ||
}, | ||
{ | ||
name: 'passengers', | ||
type: base_immutable_1.PropertyType.ARRAY, | ||
}, | ||
]; | ||
@@ -103,0 +107,0 @@ Car.BACK_COMPATS = [ |
{ | ||
"name": "immutable-class", | ||
"version": "0.9.10", | ||
"version": "0.10.0", | ||
"description": "A template for creating immutable classes", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
93018
0
100
1985
31
1