@twin.org/entity 0.0.1-next.45 → 0.0.1-next.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -563,11 +563,17 @@ class EntitySchemaHelper {
563
563
  }
564
564
  }
565
565
  else if (prop.type === "integer" && core.Is.integer(value)) ;
566
- else if (prop.type === "object" && core.Is.object(value)) ;
566
+ else if (prop.type === "object" &&
567
+ (core.Is.object(value) ||
568
+ core.Is.array(value) ||
569
+ core.Is.string(value) ||
570
+ core.Is.number(value) ||
571
+ core.Is.boolean(value) ||
572
+ core.Is.null(value))) ;
567
573
  else if (prop.type === "array" && core.Is.array(value)) ;
568
574
  else if (prop.type !== typeof value) {
569
575
  // The schema type does not match the value type
570
- throw new core.GeneralError(EntitySchemaHelper._CLASS_NAME, "invalidEntity", {
576
+ throw new core.GeneralError(EntitySchemaHelper._CLASS_NAME, "invalidEntityProperty", {
571
577
  value,
572
578
  property: prop.property,
573
579
  type: prop.type
@@ -561,11 +561,17 @@ class EntitySchemaHelper {
561
561
  }
562
562
  }
563
563
  else if (prop.type === "integer" && Is.integer(value)) ;
564
- else if (prop.type === "object" && Is.object(value)) ;
564
+ else if (prop.type === "object" &&
565
+ (Is.object(value) ||
566
+ Is.array(value) ||
567
+ Is.string(value) ||
568
+ Is.number(value) ||
569
+ Is.boolean(value) ||
570
+ Is.null(value))) ;
565
571
  else if (prop.type === "array" && Is.array(value)) ;
566
572
  else if (prop.type !== typeof value) {
567
573
  // The schema type does not match the value type
568
- throw new GeneralError(EntitySchemaHelper._CLASS_NAME, "invalidEntity", {
574
+ throw new GeneralError(EntitySchemaHelper._CLASS_NAME, "invalidEntityProperty", {
569
575
  value,
570
576
  property: prop.property,
571
577
  type: prop.type
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/entity - Changelog
2
2
 
3
- ## 0.0.1-next.45
3
+ ## 0.0.1-next.46
4
4
 
5
5
  - Initial Release
package/locales/en.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "noIsPrimary": "Property \"entitySchema.properties\" must contain a value with isPrimary set",
5
5
  "multipleIsPrimary": "Property \"entitySchema.properties\" contains more than one property with isPrimary set",
6
6
  "invalidEntityProperties": "The schema has no properties defined, but the entity has properties",
7
- "invalidEntity": "The entity value of \"{value}\" does not match the type \"{type}\" for property \"{property}\"",
7
+ "invalidEntityProperty": "The entity value of \"{value}\" does not match the type \"{type}\" for property \"{property}\"",
8
8
  "invalidOptional": "The entity property \"{property}\" of type \"{type}\" is not optional, but no value has been provided",
9
9
  "invalidEntityKeys": "The entity had additional properties that are not in the schema, \"{keys}\""
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/entity",
3
- "version": "0.0.1-next.45",
3
+ "version": "0.0.1-next.46",
4
4
  "description": "Helpers for defining and working with entities",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "0.0.1-next.45",
17
+ "@twin.org/core": "0.0.1-next.46",
18
18
  "@twin.org/nameof": "next",
19
19
  "reflect-metadata": "0.2.2"
20
20
  },