dragonfly-schema 1.12.1-v7 → 1.12.1-v8

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.
Files changed (44) hide show
  1. package/helpers/class-validator.ts +94 -0
  2. package/models/Building.ts +1 -1
  3. package/models/BuildingEnergyPropertiesAbridged.ts +1 -1
  4. package/models/BuildingPropertiesAbridged.ts +1 -1
  5. package/models/BuildingRadiancePropertiesAbridged.ts +1 -1
  6. package/models/ContextShade.ts +1 -1
  7. package/models/ContextShadeEnergyPropertiesAbridged.ts +1 -1
  8. package/models/ContextShadePropertiesAbridged.ts +1 -1
  9. package/models/ContextShadeRadiancePropertiesAbridged.ts +1 -1
  10. package/models/DetailedSkylights.ts +4 -9
  11. package/models/DetailedWindows.ts +4 -9
  12. package/models/ExteriorApertureGridParameter.ts +1 -1
  13. package/models/ExteriorFaceGridParameter.ts +1 -1
  14. package/models/ExtrudedBorder.ts +1 -1
  15. package/models/GriddedSkylightArea.ts +1 -1
  16. package/models/GriddedSkylightRatio.ts +1 -1
  17. package/models/LouversByCount.ts +1 -1
  18. package/models/LouversByDistance.ts +1 -1
  19. package/models/Model.ts +1 -1
  20. package/models/ModelEnergyProperties.ts +1 -1
  21. package/models/ModelProperties.ts +1 -1
  22. package/models/ModelRadianceProperties.ts +1 -1
  23. package/models/Overhang.ts +1 -1
  24. package/models/RectangularWindows.ts +4 -6
  25. package/models/RepeatingWindowRatio.ts +1 -1
  26. package/models/RoofSpecification.ts +1 -1
  27. package/models/Room2D.ts +5 -13
  28. package/models/Room2DEnergyPropertiesAbridged.ts +1 -1
  29. package/models/Room2DPropertiesAbridged.ts +1 -1
  30. package/models/Room2DRadiancePropertiesAbridged.ts +1 -1
  31. package/models/RoomGridParameter.ts +1 -1
  32. package/models/RoomRadialGridParameter.ts +1 -1
  33. package/models/SimpleWindowArea.ts +1 -1
  34. package/models/SimpleWindowRatio.ts +1 -1
  35. package/models/SingleWindow.ts +1 -1
  36. package/models/Story.ts +1 -1
  37. package/models/StoryEnergyPropertiesAbridged.ts +1 -1
  38. package/models/StoryPropertiesAbridged.ts +1 -1
  39. package/models/StoryRadiancePropertiesAbridged.ts +1 -1
  40. package/models/_GridParameterBase.ts +1 -1
  41. package/models/_LouversBase.ts +1 -1
  42. package/models/_WindowParameterBase.ts +1 -1
  43. package/package.json +1 -1
  44. package/tsconfig.json +1 -1
@@ -0,0 +1,94 @@
1
+ import { registerDecorator, ValidationOptions, ValidationArguments } from 'class-validator';
2
+
3
+
4
+ // Custom decorator to validate nested arrays of numbers
5
+ export function IsNestedNumberArray(validationOptions?: ValidationOptions) {
6
+ return function (object: Object, propertyName: string) {
7
+ registerDecorator({
8
+ name: 'isNestedNumberArray',
9
+ target: object.constructor,
10
+ propertyName: propertyName,
11
+ options: validationOptions,
12
+ validator: {
13
+ validate(value: any, args: ValidationArguments) {
14
+ if (value === undefined || value === null) return true; // Allow optional values
15
+ if (!Array.isArray(value)) return false;
16
+ return value.every(
17
+ (arr: any) => Array.isArray(arr) && arr.every(
18
+ (subArr: any) =>
19
+ (Array.isArray(subArr) && subArr.every(
20
+ (num: any) => typeof num === 'number'
21
+ )) ||
22
+ typeof subArr === 'number'
23
+ )
24
+ );
25
+ },
26
+ defaultMessage(args: ValidationArguments) {
27
+ return `${args.property} must be number[][] or number[][][]`;
28
+ }
29
+ }
30
+ });
31
+ };
32
+ }
33
+
34
+
35
+ // Custom decorator to validate nested arrays of numbers
36
+ export function IsNestedIntegerArray(validationOptions?: ValidationOptions) {
37
+ return function (object: Object, propertyName: string) {
38
+ registerDecorator({
39
+ name: 'isNestedIntegerArray',
40
+ target: object.constructor,
41
+ propertyName: propertyName,
42
+ options: validationOptions,
43
+ validator: {
44
+ validate(value: any, args: ValidationArguments) {
45
+ if (value === undefined || value === null) return true; // Allow optional values
46
+ if (!Array.isArray(value)) return false;
47
+ return value.every(
48
+ (arr: any) => Array.isArray(arr) && arr.every(
49
+ (subArr: any) =>
50
+ (Array.isArray(subArr) && subArr.every(
51
+ (num: any) => Number.isInteger(num)
52
+ )) ||
53
+ Number.isInteger(subArr)
54
+ )
55
+ );
56
+ },
57
+ defaultMessage(args: ValidationArguments) {
58
+ return `${args.property} must be number[][] or number[][][]`;
59
+ }
60
+ }
61
+ });
62
+ };
63
+ }
64
+
65
+
66
+ // Custom decorator to validate nested arrays of numbers
67
+ export function IsNestedStringArray(validationOptions?: ValidationOptions) {
68
+ return function (object: Object, propertyName: string) {
69
+ registerDecorator({
70
+ name: 'isNestedStringArray',
71
+ target: object.constructor,
72
+ propertyName: propertyName,
73
+ options: validationOptions,
74
+ validator: {
75
+ validate(value: any, args: ValidationArguments) {
76
+ if (value === undefined || value === null) return true; // Allow optional values
77
+ if (!Array.isArray(value)) return false;
78
+ return value.every(
79
+ (arr: any) => Array.isArray(arr) && arr.every(
80
+ (subArr: any) =>
81
+ (Array.isArray(subArr) && subArr.every(
82
+ (num: any) => typeof num === 'string'
83
+ )) ||
84
+ typeof subArr === 'string'
85
+ )
86
+ );
87
+ },
88
+ defaultMessage(args: ValidationArguments) {
89
+ return `${args.property} must be string[][] or string[][][]`;
90
+ }
91
+ }
92
+ });
93
+ };
94
+ }
@@ -90,7 +90,7 @@ export class Building extends IDdBaseModel {
90
90
  async validate(): Promise<boolean> {
91
91
  const errors = await validate(this);
92
92
  if (errors.length > 0){
93
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
93
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
94
94
  throw new Error(`Validation failed: ${errorMessages}`);
95
95
  }
96
96
  return true;
@@ -57,7 +57,7 @@ export class BuildingEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
57
57
  async validate(): Promise<boolean> {
58
58
  const errors = await validate(this);
59
59
  if (errors.length > 0){
60
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
60
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
61
61
  throw new Error(`Validation failed: ${errorMessages}`);
62
62
  }
63
63
  return true;
@@ -65,7 +65,7 @@ export class BuildingPropertiesAbridged extends _OpenAPIGenBaseModel {
65
65
  async validate(): Promise<boolean> {
66
66
  const errors = await validate(this);
67
67
  if (errors.length > 0){
68
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
69
69
  throw new Error(`Validation failed: ${errorMessages}`);
70
70
  }
71
71
  return true;
@@ -55,7 +55,7 @@ export class BuildingRadiancePropertiesAbridged extends _OpenAPIGenBaseModel {
55
55
  async validate(): Promise<boolean> {
56
56
  const errors = await validate(this);
57
57
  if (errors.length > 0){
58
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
58
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
59
59
  throw new Error(`Validation failed: ${errorMessages}`);
60
60
  }
61
61
  return true;
@@ -75,7 +75,7 @@ export class ContextShade extends IDdBaseModel {
75
75
  async validate(): Promise<boolean> {
76
76
  const errors = await validate(this);
77
77
  if (errors.length > 0){
78
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
78
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
79
79
  throw new Error(`Validation failed: ${errorMessages}`);
80
80
  }
81
81
  return true;
@@ -66,7 +66,7 @@ export class ContextShadeEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
66
66
  async validate(): Promise<boolean> {
67
67
  const errors = await validate(this);
68
68
  if (errors.length > 0){
69
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
69
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
70
70
  throw new Error(`Validation failed: ${errorMessages}`);
71
71
  }
72
72
  return true;
@@ -65,7 +65,7 @@ export class ContextShadePropertiesAbridged extends _OpenAPIGenBaseModel {
65
65
  async validate(): Promise<boolean> {
66
66
  const errors = await validate(this);
67
67
  if (errors.length > 0){
68
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
69
69
  throw new Error(`Validation failed: ${errorMessages}`);
70
70
  }
71
71
  return true;
@@ -55,7 +55,7 @@ export class ContextShadeRadiancePropertiesAbridged extends _OpenAPIGenBaseModel
55
55
  async validate(): Promise<boolean> {
56
56
  const errors = await validate(this);
57
57
  if (errors.length > 0){
58
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
58
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
59
59
  throw new Error(`Validation failed: ${errorMessages}`);
60
60
  }
61
61
  return true;
@@ -1,17 +1,12 @@
1
- import { IsArray, ValidateNested, IsNumber, IsDefined, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
1
+ import { IsArray, IsDefined, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
2
2
  import { Type, plainToClass } from 'class-transformer';
3
+ import { IsNestedNumberArray } from "./../helpers/class-validator";
3
4
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
5
 
5
6
  /** Several detailed skylights defined by 2D Polygons (lists of 2D vertices). */
6
7
  export class DetailedSkylights extends _OpenAPIGenBaseModel {
7
8
  @IsArray()
8
- @IsArray({ each: true })
9
- @ValidateNested({each: true })
10
- @Type(() => Array)
11
- @IsArray({ each: true })
12
- @ValidateNested({each: true })
13
- @Type(() => Array)
14
- @IsNumber({},{ each: true })
9
+ @IsNestedNumberArray()
15
10
  @IsDefined()
16
11
  /** An array of arrays with each sub-array representing a polygonal boundary of a skylight. Each sub-array should consist of arrays representing points, which contain 2 values for 2D coordinates in the world XY system. These coordinate values should lie within the parent Room2D Polygon. */
17
12
  polygons!: number [] [] [];
@@ -70,7 +65,7 @@ export class DetailedSkylights extends _OpenAPIGenBaseModel {
70
65
  async validate(): Promise<boolean> {
71
66
  const errors = await validate(this);
72
67
  if (errors.length > 0){
73
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
74
69
  throw new Error(`Validation failed: ${errorMessages}`);
75
70
  }
76
71
  return true;
@@ -1,17 +1,12 @@
1
- import { IsArray, ValidateNested, IsNumber, IsDefined, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
1
+ import { IsArray, IsDefined, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
2
2
  import { Type, plainToClass } from 'class-transformer';
3
+ import { IsNestedNumberArray } from "./../helpers/class-validator";
3
4
  import { _WindowParameterBase } from "./_WindowParameterBase";
4
5
 
5
6
  /** Several detailed windows defined by 2D Polygons (lists of 2D vertices). */
6
7
  export class DetailedWindows extends _WindowParameterBase {
7
8
  @IsArray()
8
- @IsArray({ each: true })
9
- @ValidateNested({each: true })
10
- @Type(() => Array)
11
- @IsArray({ each: true })
12
- @ValidateNested({each: true })
13
- @Type(() => Array)
14
- @IsNumber({},{ each: true })
9
+ @IsNestedNumberArray()
15
10
  @IsDefined()
16
11
  /** An array of arrays with each sub-array representing a polygonal boundary of a window. Each sub-array should consist of arrays representing points, which can either contain 2 values (indicating they are 2D vertices within the plane of a parent wall segment) or they can contain 3 values (indicating they are 3D world coordinates). For 2D points, the wall plane is assumed to have an origin at the first point of the wall segment and an X-axis extending along the length of the segment. The wall plane Y-axis always points upwards. Therefore, both X and Y values of each point in the polygon should always be positive. Some sample code to convert from 2D vertices to 2D vertices in the plane of the wall can be found here: https://www.ladybug.tools/dragonfly-core/docs/dragonfly.windowparameter.html#dragonfly.windowparameter.DetailedWindows */
17
12
  polygons!: number [] [] [];
@@ -70,7 +65,7 @@ export class DetailedWindows extends _WindowParameterBase {
70
65
  async validate(): Promise<boolean> {
71
66
  const errors = await validate(this);
72
67
  if (errors.length > 0){
73
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
74
69
  throw new Error(`Validation failed: ${errorMessages}`);
75
70
  }
76
71
  return true;
@@ -66,7 +66,7 @@ export class ExteriorApertureGridParameter extends _GridParameterBase {
66
66
  async validate(): Promise<boolean> {
67
67
  const errors = await validate(this);
68
68
  if (errors.length > 0){
69
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
69
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
70
70
  throw new Error(`Validation failed: ${errorMessages}`);
71
71
  }
72
72
  return true;
@@ -74,7 +74,7 @@ export class ExteriorFaceGridParameter extends _GridParameterBase {
74
74
  async validate(): Promise<boolean> {
75
75
  const errors = await validate(this);
76
76
  if (errors.length > 0){
77
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
77
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
78
78
  throw new Error(`Validation failed: ${errorMessages}`);
79
79
  }
80
80
  return true;
@@ -55,7 +55,7 @@ export class ExtrudedBorder extends _OpenAPIGenBaseModel {
55
55
  async validate(): Promise<boolean> {
56
56
  const errors = await validate(this);
57
57
  if (errors.length > 0){
58
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
58
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
59
59
  throw new Error(`Validation failed: ${errorMessages}`);
60
60
  }
61
61
  return true;
@@ -63,7 +63,7 @@ export class GriddedSkylightArea extends _OpenAPIGenBaseModel {
63
63
  async validate(): Promise<boolean> {
64
64
  const errors = await validate(this);
65
65
  if (errors.length > 0){
66
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
66
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
67
67
  throw new Error(`Validation failed: ${errorMessages}`);
68
68
  }
69
69
  return true;
@@ -63,7 +63,7 @@ export class GriddedSkylightRatio extends _OpenAPIGenBaseModel {
63
63
  async validate(): Promise<boolean> {
64
64
  const errors = await validate(this);
65
65
  if (errors.length > 0){
66
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
66
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
67
67
  throw new Error(`Validation failed: ${errorMessages}`);
68
68
  }
69
69
  return true;
@@ -55,7 +55,7 @@ export class LouversByCount extends _LouversBase {
55
55
  async validate(): Promise<boolean> {
56
56
  const errors = await validate(this);
57
57
  if (errors.length > 0){
58
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
58
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
59
59
  throw new Error(`Validation failed: ${errorMessages}`);
60
60
  }
61
61
  return true;
@@ -55,7 +55,7 @@ export class LouversByDistance extends _LouversBase {
55
55
  async validate(): Promise<boolean> {
56
56
  const errors = await validate(this);
57
57
  if (errors.length > 0){
58
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
58
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
59
59
  throw new Error(`Validation failed: ${errorMessages}`);
60
60
  }
61
61
  return true;
package/models/Model.ts CHANGED
@@ -117,7 +117,7 @@ export class Model extends IDdBaseModel {
117
117
  async validate(): Promise<boolean> {
118
118
  const errors = await validate(this);
119
119
  if (errors.length > 0){
120
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
120
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
121
121
  throw new Error(`Validation failed: ${errorMessages}`);
122
122
  }
123
123
  return true;
@@ -598,7 +598,7 @@ export class ModelEnergyProperties extends _OpenAPIGenBaseModel {
598
598
  async validate(): Promise<boolean> {
599
599
  const errors = await validate(this);
600
600
  if (errors.length > 0){
601
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
601
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
602
602
  throw new Error(`Validation failed: ${errorMessages}`);
603
603
  }
604
604
  return true;
@@ -65,7 +65,7 @@ export class ModelProperties extends _OpenAPIGenBaseModel {
65
65
  async validate(): Promise<boolean> {
66
66
  const errors = await validate(this);
67
67
  if (errors.length > 0){
68
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
69
69
  throw new Error(`Validation failed: ${errorMessages}`);
70
70
  }
71
71
  return true;
@@ -245,7 +245,7 @@ export class ModelRadianceProperties extends _OpenAPIGenBaseModel {
245
245
  async validate(): Promise<boolean> {
246
246
  const errors = await validate(this);
247
247
  if (errors.length > 0){
248
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
248
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
249
249
  throw new Error(`Validation failed: ${errorMessages}`);
250
250
  }
251
251
  return true;
@@ -65,7 +65,7 @@ export class Overhang extends _OpenAPIGenBaseModel {
65
65
  async validate(): Promise<boolean> {
66
66
  const errors = await validate(this);
67
67
  if (errors.length > 0){
68
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
69
69
  throw new Error(`Validation failed: ${errorMessages}`);
70
70
  }
71
71
  return true;
@@ -1,14 +1,12 @@
1
- import { IsArray, ValidateNested, IsNumber, IsDefined, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
1
+ import { IsArray, IsDefined, IsNumber, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
2
2
  import { Type, plainToClass } from 'class-transformer';
3
+ import { IsNestedNumberArray } from "./../helpers/class-validator";
3
4
  import { _WindowParameterBase } from "./_WindowParameterBase";
4
5
 
5
6
  /** Several rectangular windows, defined by origin, width and height. */
6
7
  export class RectangularWindows extends _WindowParameterBase {
7
8
  @IsArray()
8
- @IsArray({ each: true })
9
- @ValidateNested({each: true })
10
- @Type(() => Array)
11
- @IsNumber({},{ each: true })
9
+ @IsNestedNumberArray()
12
10
  @IsDefined()
13
11
  /** An array of 2D points within the plane of the wall for the origin of each window. Each point should be a list of 2 (x, y) values. The wall plane is assumed to have an origin at the first point of the wall segment and an X-axis extending along the length of the segment. The wall plane Y-axis always points upwards. Therefore, both X and Y values of each origin point should be positive. */
14
12
  origins!: number [] [];
@@ -83,7 +81,7 @@ export class RectangularWindows extends _WindowParameterBase {
83
81
  async validate(): Promise<boolean> {
84
82
  const errors = await validate(this);
85
83
  if (errors.length > 0){
86
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
84
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
87
85
  throw new Error(`Validation failed: ${errorMessages}`);
88
86
  }
89
87
  return true;
@@ -86,7 +86,7 @@ export class RepeatingWindowRatio extends _WindowParameterBase {
86
86
  async validate(): Promise<boolean> {
87
87
  const errors = await validate(this);
88
88
  if (errors.length > 0){
89
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
89
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
90
90
  throw new Error(`Validation failed: ${errorMessages}`);
91
91
  }
92
92
  return true;
@@ -59,7 +59,7 @@ export class RoofSpecification extends _OpenAPIGenBaseModel {
59
59
  async validate(): Promise<boolean> {
60
60
  const errors = await validate(this);
61
61
  if (errors.length > 0){
62
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
62
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
63
63
  throw new Error(`Validation failed: ${errorMessages}`);
64
64
  }
65
65
  return true;
package/models/Room2D.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { IsArray, ValidateNested, IsNumber, IsDefined, IsInstance, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
1
+ import { IsArray, IsDefined, IsNumber, IsInstance, ValidateNested, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
2
2
  import { Type, plainToClass } from 'class-transformer';
3
+ import { IsNestedNumberArray } from "./../helpers/class-validator";
3
4
  import { Adiabatic } from "honeybee-schema";
4
5
  import { DetailedSkylights } from "./DetailedSkylights";
5
6
  import { DetailedWindows } from "./DetailedWindows";
@@ -24,10 +25,7 @@ import { Surface } from "honeybee-schema";
24
25
  /** Base class for all objects requiring a identifiers acceptable for all engines. */
25
26
  export class Room2D extends IDdBaseModel {
26
27
  @IsArray()
27
- @IsArray({ each: true })
28
- @ValidateNested({each: true })
29
- @Type(() => Array)
30
- @IsNumber({},{ each: true })
28
+ @IsNestedNumberArray()
31
29
  @IsDefined()
32
30
  /** A list of 2D points representing the outer boundary vertices of the Room2D. The list should include at least 3 points and each point should be a list of 2 (x, y) values. */
33
31
  floor_boundary!: number [] [];
@@ -55,13 +53,7 @@ export class Room2D extends IDdBaseModel {
55
53
  type?: string;
56
54
 
57
55
  @IsArray()
58
- @IsArray({ each: true })
59
- @ValidateNested({each: true })
60
- @Type(() => Array)
61
- @IsArray({ each: true })
62
- @ValidateNested({each: true })
63
- @Type(() => Array)
64
- @IsNumber({},{ each: true })
56
+ @IsNestedNumberArray()
65
57
  @IsOptional()
66
58
  /** Optional list of lists with one list for each hole in the floor plate. Each hole should be a list of at least 2 points and each point a list of 2 (x, y) values. If None, it will be assumed that there are no holes in the floor plate. */
67
59
  floor_holes?: number [] [] [];
@@ -166,7 +158,7 @@ export class Room2D extends IDdBaseModel {
166
158
  async validate(): Promise<boolean> {
167
159
  const errors = await validate(this);
168
160
  if (errors.length > 0){
169
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
161
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
170
162
  throw new Error(`Validation failed: ${errorMessages}`);
171
163
  }
172
164
  return true;
@@ -115,7 +115,7 @@ export class Room2DEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
115
115
  async validate(): Promise<boolean> {
116
116
  const errors = await validate(this);
117
117
  if (errors.length > 0){
118
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
118
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
119
119
  throw new Error(`Validation failed: ${errorMessages}`);
120
120
  }
121
121
  return true;
@@ -65,7 +65,7 @@ export class Room2DPropertiesAbridged extends _OpenAPIGenBaseModel {
65
65
  async validate(): Promise<boolean> {
66
66
  const errors = await validate(this);
67
67
  if (errors.length > 0){
68
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
69
69
  throw new Error(`Validation failed: ${errorMessages}`);
70
70
  }
71
71
  return true;
@@ -66,7 +66,7 @@ export class Room2DRadiancePropertiesAbridged extends _OpenAPIGenBaseModel {
66
66
  async validate(): Promise<boolean> {
67
67
  const errors = await validate(this);
68
68
  if (errors.length > 0){
69
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
69
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
70
70
  throw new Error(`Validation failed: ${errorMessages}`);
71
71
  }
72
72
  return true;
@@ -64,7 +64,7 @@ export class RoomGridParameter extends _GridParameterBase {
64
64
  async validate(): Promise<boolean> {
65
65
  const errors = await validate(this);
66
66
  if (errors.length > 0){
67
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
67
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
68
68
  throw new Error(`Validation failed: ${errorMessages}`);
69
69
  }
70
70
  return true;
@@ -72,7 +72,7 @@ export class RoomRadialGridParameter extends RoomGridParameter {
72
72
  async validate(): Promise<boolean> {
73
73
  const errors = await validate(this);
74
74
  if (errors.length > 0){
75
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
75
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
76
76
  throw new Error(`Validation failed: ${errorMessages}`);
77
77
  }
78
78
  return true;
@@ -63,7 +63,7 @@ export class SimpleWindowArea extends _WindowParameterBase {
63
63
  async validate(): Promise<boolean> {
64
64
  const errors = await validate(this);
65
65
  if (errors.length > 0){
66
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
66
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
67
67
  throw new Error(`Validation failed: ${errorMessages}`);
68
68
  }
69
69
  return true;
@@ -63,7 +63,7 @@ export class SimpleWindowRatio extends _WindowParameterBase {
63
63
  async validate(): Promise<boolean> {
64
64
  const errors = await validate(this);
65
65
  if (errors.length > 0){
66
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
66
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
67
67
  throw new Error(`Validation failed: ${errorMessages}`);
68
68
  }
69
69
  return true;
@@ -70,7 +70,7 @@ export class SingleWindow extends _WindowParameterBase {
70
70
  async validate(): Promise<boolean> {
71
71
  const errors = await validate(this);
72
72
  if (errors.length > 0){
73
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
73
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
74
74
  throw new Error(`Validation failed: ${errorMessages}`);
75
75
  }
76
76
  return true;
package/models/Story.ts CHANGED
@@ -103,7 +103,7 @@ export class Story extends IDdBaseModel {
103
103
  async validate(): Promise<boolean> {
104
104
  const errors = await validate(this);
105
105
  if (errors.length > 0){
106
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
106
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
107
107
  throw new Error(`Validation failed: ${errorMessages}`);
108
108
  }
109
109
  return true;
@@ -57,7 +57,7 @@ export class StoryEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
57
57
  async validate(): Promise<boolean> {
58
58
  const errors = await validate(this);
59
59
  if (errors.length > 0){
60
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
60
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
61
61
  throw new Error(`Validation failed: ${errorMessages}`);
62
62
  }
63
63
  return true;
@@ -65,7 +65,7 @@ export class StoryPropertiesAbridged extends _OpenAPIGenBaseModel {
65
65
  async validate(): Promise<boolean> {
66
66
  const errors = await validate(this);
67
67
  if (errors.length > 0){
68
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
69
69
  throw new Error(`Validation failed: ${errorMessages}`);
70
70
  }
71
71
  return true;
@@ -55,7 +55,7 @@ export class StoryRadiancePropertiesAbridged extends _OpenAPIGenBaseModel {
55
55
  async validate(): Promise<boolean> {
56
56
  const errors = await validate(this);
57
57
  if (errors.length > 0){
58
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
58
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
59
59
  throw new Error(`Validation failed: ${errorMessages}`);
60
60
  }
61
61
  return true;
@@ -63,7 +63,7 @@ export class _GridParameterBase extends _OpenAPIGenBaseModel {
63
63
  async validate(): Promise<boolean> {
64
64
  const errors = await validate(this);
65
65
  if (errors.length > 0){
66
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
66
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
67
67
  throw new Error(`Validation failed: ${errorMessages}`);
68
68
  }
69
69
  return true;
@@ -91,7 +91,7 @@ export class _LouversBase extends _OpenAPIGenBaseModel {
91
91
  async validate(): Promise<boolean> {
92
92
  const errors = await validate(this);
93
93
  if (errors.length > 0){
94
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
94
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
95
95
  throw new Error(`Validation failed: ${errorMessages}`);
96
96
  }
97
97
  return true;
@@ -54,7 +54,7 @@ export class _WindowParameterBase extends _OpenAPIGenBaseModel {
54
54
  async validate(): Promise<boolean> {
55
55
  const errors = await validate(this);
56
56
  if (errors.length > 0){
57
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
57
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
58
58
  throw new Error(`Validation failed: ${errorMessages}`);
59
59
  }
60
60
  return true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dragonfly-schema",
3
3
  "license": "MIT",
4
- "version": "1.12.1-v7",
4
+ "version": "1.12.1-v8",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsc && vite build",
package/tsconfig.json CHANGED
@@ -27,6 +27,6 @@
27
27
 
28
28
  "noFallthroughCasesInSwitch": true
29
29
  },
30
- "include": [ "models"],
30
+ "include": [ "models", "helpers"],
31
31
  "exclude": ["node_modules"]
32
32
  }