@wisemen/quantity 0.3.6 → 0.4.1

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 (92) hide show
  1. package/dist/quantities/current/current.column.d.ts +3 -2
  2. package/dist/quantities/current/current.column.js.map +1 -1
  3. package/dist/quantities/current/index.d.ts +1 -0
  4. package/dist/quantities/current/index.js +1 -0
  5. package/dist/quantities/current/index.js.map +1 -1
  6. package/dist/quantities/current/is-current.validator.d.ts +4 -0
  7. package/dist/quantities/current/is-current.validator.js +7 -0
  8. package/dist/quantities/current/is-current.validator.js.map +1 -0
  9. package/dist/quantities/distance/distance.column.d.ts +3 -2
  10. package/dist/quantities/distance/distance.column.js.map +1 -1
  11. package/dist/quantities/distance/distance.d.ts +0 -6
  12. package/dist/quantities/distance/distance.dto.d.ts +2 -1
  13. package/dist/quantities/distance/distance.dto.js +2 -1
  14. package/dist/quantities/distance/distance.dto.js.map +1 -1
  15. package/dist/quantities/distance/distance.js +0 -15
  16. package/dist/quantities/distance/distance.js.map +1 -1
  17. package/dist/quantities/distance/index.d.ts +1 -0
  18. package/dist/quantities/distance/index.js +1 -0
  19. package/dist/quantities/distance/index.js.map +1 -1
  20. package/dist/quantities/distance/is-distance.validator.d.ts +4 -0
  21. package/dist/quantities/distance/is-distance.validator.js +7 -0
  22. package/dist/quantities/distance/is-distance.validator.js.map +1 -0
  23. package/dist/quantities/distance/tests/distance.unit.test.js +0 -9
  24. package/dist/quantities/distance/tests/distance.unit.test.js.map +1 -1
  25. package/dist/quantities/duration/duration.column.d.ts +3 -2
  26. package/dist/quantities/duration/duration.column.js.map +1 -1
  27. package/dist/quantities/duration/index.d.ts +1 -0
  28. package/dist/quantities/duration/index.js +1 -0
  29. package/dist/quantities/duration/index.js.map +1 -1
  30. package/dist/quantities/duration/is-duration.validator.d.ts +4 -0
  31. package/dist/quantities/duration/is-duration.validator.js +7 -0
  32. package/dist/quantities/duration/is-duration.validator.js.map +1 -0
  33. package/dist/quantities/energy/energy.column.d.ts +3 -2
  34. package/dist/quantities/energy/energy.column.js.map +1 -1
  35. package/dist/quantities/energy/index.d.ts +1 -0
  36. package/dist/quantities/energy/index.js +1 -0
  37. package/dist/quantities/energy/index.js.map +1 -1
  38. package/dist/quantities/energy/is-energy.validator.d.ts +4 -0
  39. package/dist/quantities/energy/is-energy.validator.js +7 -0
  40. package/dist/quantities/energy/is-energy.validator.js.map +1 -0
  41. package/dist/quantities/mass/index.d.ts +1 -0
  42. package/dist/quantities/mass/index.js +1 -0
  43. package/dist/quantities/mass/index.js.map +1 -1
  44. package/dist/quantities/mass/is-mass.validator.d.ts +4 -0
  45. package/dist/quantities/mass/is-mass.validator.js +7 -0
  46. package/dist/quantities/mass/is-mass.validator.js.map +1 -0
  47. package/dist/quantities/mass/mass.column.d.ts +3 -2
  48. package/dist/quantities/mass/mass.column.js.map +1 -1
  49. package/dist/quantities/mass/mass.dto.d.ts +2 -1
  50. package/dist/quantities/mass/mass.dto.js +2 -1
  51. package/dist/quantities/mass/mass.dto.js.map +1 -1
  52. package/dist/quantities/power/index.d.ts +1 -0
  53. package/dist/quantities/power/index.js +1 -0
  54. package/dist/quantities/power/index.js.map +1 -1
  55. package/dist/quantities/power/is-power.validator.d.ts +4 -0
  56. package/dist/quantities/power/is-power.validator.js +7 -0
  57. package/dist/quantities/power/is-power.validator.js.map +1 -0
  58. package/dist/quantities/power/power.column.d.ts +3 -2
  59. package/dist/quantities/power/power.column.js.map +1 -1
  60. package/dist/quantities/speed/index.d.ts +1 -0
  61. package/dist/quantities/speed/index.js +1 -0
  62. package/dist/quantities/speed/index.js.map +1 -1
  63. package/dist/quantities/speed/is-speed.validator.d.ts +4 -0
  64. package/dist/quantities/speed/is-speed.validator.js +7 -0
  65. package/dist/quantities/speed/is-speed.validator.js.map +1 -0
  66. package/dist/quantities/speed/speed.column.d.ts +3 -2
  67. package/dist/quantities/speed/speed.column.js.map +1 -1
  68. package/dist/quantities/temperature/index.d.ts +1 -0
  69. package/dist/quantities/temperature/index.js +1 -0
  70. package/dist/quantities/temperature/index.js.map +1 -1
  71. package/dist/quantities/temperature/is-temperature.validator.d.ts +4 -0
  72. package/dist/quantities/temperature/is-temperature.validator.js +7 -0
  73. package/dist/quantities/temperature/is-temperature.validator.js.map +1 -0
  74. package/dist/quantity.column.d.ts +5 -1
  75. package/dist/quantity.column.js +5 -6
  76. package/dist/quantity.column.js.map +1 -1
  77. package/dist/quantity.dto.d.ts +4 -0
  78. package/dist/quantity.dto.js +3 -0
  79. package/dist/quantity.dto.js.map +1 -0
  80. package/dist/validators/is-quantity.decorator.d.ts +9 -0
  81. package/dist/validators/is-quantity.decorator.js +22 -0
  82. package/dist/validators/is-quantity.decorator.js.map +1 -0
  83. package/dist/validators/max-quantity.validator.d.ts +8 -0
  84. package/dist/validators/max-quantity.validator.js +18 -0
  85. package/dist/validators/max-quantity.validator.js.map +1 -0
  86. package/dist/validators/min-quantity.validator.d.ts +8 -0
  87. package/dist/validators/min-quantity.validator.js +18 -0
  88. package/dist/validators/min-quantity.validator.js.map +1 -0
  89. package/dist/validators/tests/is-quantity.decorator.unit.test.d.ts +1 -0
  90. package/dist/validators/tests/is-quantity.decorator.unit.test.js +170 -0
  91. package/dist/validators/tests/is-quantity.decorator.unit.test.js.map +1 -0
  92. package/package.json +28 -23
@@ -1,3 +1,4 @@
1
- import { ColumnOptions } from 'typeorm';
1
+ import { QuantityColumnOptions } from '../../quantity.column.js';
2
2
  import { CurrentUnit } from './current-unit.enum.js';
3
- export declare function CurrentColumn(storeAsUnit: CurrentUnit, options?: Omit<ColumnOptions, 'type' | 'transformer'>): PropertyDecorator;
3
+ import { Current } from './current.js';
4
+ export declare function CurrentColumn(storeAsUnit: CurrentUnit, options?: QuantityColumnOptions<CurrentUnit, Current>): PropertyDecorator;
@@ -1 +1 @@
1
- {"version":3,"file":"current.column.js","sourceRoot":"","sources":["../../../lib/quantities/current/current.column.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,UAAU,aAAa,CAC3B,WAAwB,EACxB,OAAqD;IAErD,OAAO,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACtD,CAAC"}
1
+ {"version":3,"file":"current.column.js","sourceRoot":"","sources":["../../../lib/quantities/current/current.column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAyB,MAAM,0BAA0B,CAAA;AAEhF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,UAAU,aAAa,CAC3B,WAAwB,EACxB,OAAqD;IAErD,OAAO,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACtD,CAAC"}
@@ -2,3 +2,4 @@ export * from './current.js';
2
2
  export * from './current.dto.js';
3
3
  export * from './current.column.js';
4
4
  export * from './current-unit.enum.js';
5
+ export * from './is-current.validator.js';
@@ -2,4 +2,5 @@ export * from './current.js';
2
2
  export * from './current.dto.js';
3
3
  export * from './current.column.js';
4
4
  export * from './current-unit.enum.js';
5
+ export * from './is-current.validator.js';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/current/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/current/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { IsQuantityOptions } from '../../validators/is-quantity.decorator.js';
2
+ import { CurrentUnit } from './current-unit.enum.js';
3
+ import { Current } from './current.js';
4
+ export declare function IsCurrent(options?: IsQuantityOptions<CurrentUnit, Current>): PropertyDecorator;
@@ -0,0 +1,7 @@
1
+ import { applyDecorators } from '@nestjs/common';
2
+ import { IsQuantity } from '../../validators/is-quantity.decorator.js';
3
+ import { CurrentDto } from './current.dto.js';
4
+ export function IsCurrent(options) {
5
+ return applyDecorators(IsQuantity(CurrentDto, options));
6
+ }
7
+ //# sourceMappingURL=is-current.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-current.validator.js","sourceRoot":"","sources":["../../../lib/quantities/current/is-current.validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAqB,MAAM,2CAA2C,CAAA;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAI7C,MAAM,UAAU,SAAS,CACvB,OAAiD;IAEjD,OAAO,eAAe,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAA;AACzD,CAAC"}
@@ -1,3 +1,4 @@
1
- import { ColumnOptions } from 'typeorm';
1
+ import { QuantityColumnOptions } from '../../quantity.column.js';
2
2
  import { DistanceUnit } from './distance-unit.enum.js';
3
- export declare function DistanceColumn(storeAsUnit: DistanceUnit, options?: Omit<ColumnOptions, 'type' | 'transformer'>): PropertyDecorator;
3
+ import { Distance } from './distance.js';
4
+ export declare function DistanceColumn(storeAsUnit: DistanceUnit, options?: QuantityColumnOptions<DistanceUnit, Distance>): PropertyDecorator;
@@ -1 +1 @@
1
- {"version":3,"file":"distance.column.js","sourceRoot":"","sources":["../../../lib/quantities/distance/distance.column.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,MAAM,UAAU,cAAc,CAC5B,WAAyB,EACzB,OAAqD;IAErD,OAAO,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACvD,CAAC"}
1
+ {"version":3,"file":"distance.column.js","sourceRoot":"","sources":["../../../lib/quantities/distance/distance.column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAyB,MAAM,0BAA0B,CAAA;AAEhF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,MAAM,UAAU,cAAc,CAC5B,WAAyB,EACzB,OAAuD;IAEvD,OAAO,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACvD,CAAC"}
@@ -1,15 +1,9 @@
1
1
  import { Quantity } from '../../quantity.js';
2
- import { Duration } from '../duration/duration.js';
3
- import { Speed } from '../speed/speed.js';
4
2
  import { DistanceUnit } from './distance-unit.enum.js';
5
3
  export declare class Distance extends Quantity<DistanceUnit, Distance> {
6
4
  protected baseUnit: DistanceUnit;
7
5
  protected convertValueToBaseUnit(value: number, fromUnit: DistanceUnit): number;
8
6
  protected convertBaseUnitValueTo(value: number, toUnit: DistanceUnit): number;
9
- divide(divisor: number): Distance;
10
- divide(value: number, unit: DistanceUnit): number;
11
- divide(distance: Distance): number;
12
- divide(duration: Duration): Speed;
13
7
  get meters(): number;
14
8
  get kilometers(): number;
15
9
  }
@@ -1,6 +1,7 @@
1
+ import { QuantityDto } from '../../quantity.dto.js';
1
2
  import { Distance } from './distance.js';
2
3
  import { DistanceUnit } from './distance-unit.enum.js';
3
- export declare class DistanceDto {
4
+ export declare class DistanceDto extends QuantityDto<Distance> {
4
5
  value: number;
5
6
  unit: DistanceUnit;
6
7
  static from(distance: undefined): undefined;
@@ -9,9 +9,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { ApiProperty } from '@nestjs/swagger';
11
11
  import { IsEnum, IsNumber } from 'class-validator';
12
+ import { QuantityDto } from '../../quantity.dto.js';
12
13
  import { Distance } from './distance.js';
13
14
  import { DistanceUnit, DistanceUnitApiProperty } from './distance-unit.enum.js';
14
- export class DistanceDto {
15
+ export class DistanceDto extends QuantityDto {
15
16
  value;
16
17
  unit;
17
18
  static from(distance) {
@@ -1 +1 @@
1
- {"version":3,"file":"distance.dto.js","sourceRoot":"","sources":["../../../lib/quantities/distance/distance.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAE/E,MAAM,OAAO,WAAW;IAGtB,KAAK,CAAQ;IAIb,IAAI,CAAc;IASlB,MAAM,CAAC,IAAI,CAAE,QAAqC;QAChD,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;QAClC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,SAAS,CAAA;QAE5C,OAAO,IAAI,kBAAkB,EAAE;aAC5B,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;aACzB,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;aACvB,KAAK,EAAE,CAAA;IACZ,CAAC;IAED,KAAK;QACH,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IAC5C,CAAC;CACF;AA1BC;IAFC,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,EAAE;;0CACE;AAIb;IAFC,uBAAuB,EAAE;IACzB,MAAM,CAAC,YAAY,CAAC;;yCACH;AAwBpB,MAAM,OAAO,kBAAkB;IACZ,GAAG,CAAa;IAEjC;QACE,IAAI,CAAC,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;QAC5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C,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IAC5C,CAAC;CACF;AA1BC;IAFC,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,EAAE;;0CACE;AAIb;IAFC,uBAAuB,EAAE;IACzB,MAAM,CAAC,YAAY,CAAC;;yCACH;AAwBpB,MAAM,OAAO,kBAAkB;IACZ,GAAG,CAAa;IAEjC;QACE,IAAI,CAAC,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;QAC5B,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAA;QAClB,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,YAAY,CAAC,KAAK,CAAA;IACpC,CAAC;IAED,SAAS,CAAE,KAAa;QACtB,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,CAAA;QAEtB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,QAAQ,CAAE,IAAkB;QAC1B,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;QAEpB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;CACF"}
@@ -1,7 +1,4 @@
1
1
  import { Quantity } from '../../quantity.js';
2
- import { Duration } from '../duration/duration.js';
3
- import { Speed } from '../speed/speed.js';
4
- import { SpeedUnit } from '../speed/speed-unit.enum.js';
5
2
  import { DistanceUnit } from './distance-unit.enum.js';
6
3
  const DISTANCE_MULTIPLIERS = {
7
4
  [DistanceUnit.METER]: 1,
@@ -26,18 +23,6 @@ export class Distance extends Quantity {
26
23
  convertBaseUnitValueTo(value, toUnit) {
27
24
  return value / DISTANCE_MULTIPLIERS[toUnit];
28
25
  }
29
- divide(divisor, unit) {
30
- if (divisor instanceof Duration) {
31
- return new Speed(this.valueOf() / divisor.valueOf(), SpeedUnit.METER_PER_SECOND);
32
- }
33
- if (divisor instanceof Distance) {
34
- return super.divide(divisor);
35
- }
36
- if (unit !== undefined) {
37
- return super.divide(divisor, unit);
38
- }
39
- return super.divide(divisor);
40
- }
41
26
  get meters() {
42
27
  return this.asNumber(DistanceUnit.METER);
43
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"distance.js","sourceRoot":"","sources":["../../../lib/quantities/distance/distance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD,MAAM,oBAAoB,GAAiC;IACzD,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;IAEvB,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,IAAI;IAC9B,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,IAAI;IAC/B,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,IAAI;IAC/B,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,IAAI;IAC/B,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,IAAI;IAE9B,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,GAAG;IAC7B,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,GAAG;IAC9B,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,GAAG;IAE7B,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM;IAC3B,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM;IAC3B,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM;IAC3B,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,OAAO;CAC9B,CAAA;AAED,MAAM,OAAO,QAAS,SAAQ,QAAgC;IAClD,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAA;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IAAI;IAC9B,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,IAAI;IAC/B,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,IAAI;IAC/B,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,IAAI;IAC/B,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,IAAI;IAE9B,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,GAAG;IAC7B,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,GAAG;IAC9B,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,GAAG;IAE7B,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM;IAC3B,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM;IAC3B,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM;IAC3B,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,OAAO;CAC9B,CAAA;AAED,MAAM,OAAO,QAAS,SAAQ,QAAgC;IAClD,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAA;IAE7B,sBAAsB,CAAE,KAAa,EAAE,QAAsB;QACrE,OAAO,KAAK,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAC/C,CAAC;IAES,sBAAsB,CAAE,KAAa,EAAE,MAAoB;QACnE,OAAO,KAAK,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAA;IAC7C,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;IAC9C,CAAC;CACF"}
@@ -2,3 +2,4 @@ export * from './distance.js';
2
2
  export * from './distance.dto.js';
3
3
  export * from './distance.column.js';
4
4
  export * from './distance-unit.enum.js';
5
+ export * from './is-distance.validator.js';
@@ -2,4 +2,5 @@ export * from './distance.js';
2
2
  export * from './distance.dto.js';
3
3
  export * from './distance.column.js';
4
4
  export * from './distance-unit.enum.js';
5
+ export * from './is-distance.validator.js';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/distance/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/distance/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAE7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { IsQuantityOptions } from '../../validators/is-quantity.decorator.js';
2
+ import { DistanceUnit } from './distance-unit.enum.js';
3
+ import { Distance } from './distance.js';
4
+ export declare function IsDistance(options?: IsQuantityOptions<DistanceUnit, Distance>): PropertyDecorator;
@@ -0,0 +1,7 @@
1
+ import { applyDecorators } from '@nestjs/common';
2
+ import { IsQuantity } from '../../validators/is-quantity.decorator.js';
3
+ import { DistanceDto } from './distance.dto.js';
4
+ export function IsDistance(options) {
5
+ return applyDecorators(IsQuantity(DistanceDto, options));
6
+ }
7
+ //# sourceMappingURL=is-distance.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-distance.validator.js","sourceRoot":"","sources":["../../../lib/quantities/distance/is-distance.validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAqB,MAAM,2CAA2C,CAAA;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAI/C,MAAM,UAAU,UAAU,CACxB,OAAmD;IAEnD,OAAO,eAAe,CAAC,UAAU,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAA;AAC1D,CAAC"}
@@ -2,9 +2,6 @@ import { describe, it } from 'node:test';
2
2
  import { expect } from 'expect';
3
3
  import { Distance } from '../distance.js';
4
4
  import { DistanceUnit } from '../distance-unit.enum.js';
5
- import { Duration } from '../../duration/duration.js';
6
- import { DurationUnit } from '../../duration/duration-unit.enum.js';
7
- import { SpeedUnit } from '../../speed/speed-unit.enum.js';
8
5
  void describe('Distance class', () => {
9
6
  void describe('Distance calculations', () => {
10
7
  void it('adds distances', () => {
@@ -29,12 +26,6 @@ void describe('Distance class', () => {
29
26
  expect(r2).toBe(4);
30
27
  expect(r3).toBe(2);
31
28
  });
32
- void it('returns speed when divided by Duration', () => {
33
- const d = new Distance(220, DistanceUnit.KILOMETER);
34
- const t = new Duration(2, DurationUnit.HOURS);
35
- const v = d.divide(t);
36
- expect(v.isEqualTo(110, SpeedUnit.KILOMETER_PER_HOUR)).toBe(true);
37
- });
38
29
  });
39
30
  });
40
31
  //# sourceMappingURL=distance.unit.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"distance.unit.test.js","sourceRoot":"","sources":["../../../../lib/quantities/distance/tests/distance.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAG1D,KAAK,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IACnC,KAAK,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC1C,KAAK,E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EAAE,CAAC,CAAA;YAChC,MAAM,EAAE,GAAW,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC,KAAK,CAAC,CAAA;YAErD,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC5D,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAClB,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACpB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,3 +1,4 @@
1
- import { ColumnOptions } from 'typeorm';
1
+ import { QuantityColumnOptions } from '../../quantity.column.js';
2
+ import { Duration } from './duration.js';
2
3
  import { DurationUnit } from './duration-unit.enum.js';
3
- export declare function DurationColumn(storeAsUnit: DurationUnit, options?: Omit<ColumnOptions, 'type' | 'transformer'>): PropertyDecorator;
4
+ export declare function DurationColumn(storeAsUnit: DurationUnit, options?: QuantityColumnOptions<DurationUnit, Duration>): PropertyDecorator;
@@ -1 +1 @@
1
- {"version":3,"file":"duration.column.js","sourceRoot":"","sources":["../../../lib/quantities/duration/duration.column.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGxC,MAAM,UAAU,cAAc,CAC5B,WAAyB,EACzB,OAAqD;IAErD,OAAO,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACvD,CAAC"}
1
+ {"version":3,"file":"duration.column.js","sourceRoot":"","sources":["../../../lib/quantities/duration/duration.column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAyB,MAAM,0BAA0B,CAAA;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGxC,MAAM,UAAU,cAAc,CAC5B,WAAyB,EACzB,OAAuD;IAEvD,OAAO,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACvD,CAAC"}
@@ -2,3 +2,4 @@ export * from './duration.js';
2
2
  export * from './duration.dto.js';
3
3
  export * from './duration.column.js';
4
4
  export * from './duration-unit.enum.js';
5
+ export * from './is-duration.validator.js';
@@ -2,4 +2,5 @@ export * from './duration.js';
2
2
  export * from './duration.dto.js';
3
3
  export * from './duration.column.js';
4
4
  export * from './duration-unit.enum.js';
5
+ export * from './is-duration.validator.js';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/duration/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/duration/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { IsQuantityOptions } from '../../validators/is-quantity.decorator.js';
2
+ import { DurationUnit } from './duration-unit.enum.js';
3
+ import { Duration } from './duration.js';
4
+ export declare function IsDuration(options?: IsQuantityOptions<DurationUnit, Duration>): PropertyDecorator;
@@ -0,0 +1,7 @@
1
+ import { applyDecorators } from '@nestjs/common';
2
+ import { IsQuantity } from '../../validators/is-quantity.decorator.js';
3
+ import { DurationDto } from './duration.dto.js';
4
+ export function IsDuration(options) {
5
+ return applyDecorators(IsQuantity(DurationDto, options));
6
+ }
7
+ //# sourceMappingURL=is-duration.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-duration.validator.js","sourceRoot":"","sources":["../../../lib/quantities/duration/is-duration.validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAqB,MAAM,2CAA2C,CAAA;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAI/C,MAAM,UAAU,UAAU,CACxB,OAAmD;IAEnD,OAAO,eAAe,CAAC,UAAU,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAA;AAC1D,CAAC"}
@@ -1,3 +1,4 @@
1
- import { ColumnOptions } from 'typeorm';
1
+ import { QuantityColumnOptions } from '../../quantity.column.js';
2
+ import { Energy } from './energy.js';
2
3
  import { EnergyUnit } from './energy-unit.enum.js';
3
- export declare function EnergyColumn(storeAsUnit: EnergyUnit, options?: Omit<ColumnOptions, 'type' | 'transformer'>): PropertyDecorator;
4
+ export declare function EnergyColumn(storeAsUnit: EnergyUnit, options?: QuantityColumnOptions<EnergyUnit, Energy>): PropertyDecorator;
@@ -1 +1 @@
1
- {"version":3,"file":"energy.column.js","sourceRoot":"","sources":["../../../lib/quantities/energy/energy.column.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGpC,MAAM,UAAU,YAAY,CAC1B,WAAuB,EACvB,OAAqD;IAErD,OAAO,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACrD,CAAC"}
1
+ {"version":3,"file":"energy.column.js","sourceRoot":"","sources":["../../../lib/quantities/energy/energy.column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAyB,MAAM,0BAA0B,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGpC,MAAM,UAAU,YAAY,CAC1B,WAAuB,EACvB,OAAmD;IAEnD,OAAO,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACrD,CAAC"}
@@ -2,3 +2,4 @@ export * from './energy.js';
2
2
  export * from './energy.dto.js';
3
3
  export * from './energy.column.js';
4
4
  export * from './energy-unit.enum.js';
5
+ export * from './is-energy.validator.js';
@@ -2,4 +2,5 @@ export * from './energy.js';
2
2
  export * from './energy.dto.js';
3
3
  export * from './energy.column.js';
4
4
  export * from './energy-unit.enum.js';
5
+ export * from './is-energy.validator.js';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/energy/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/energy/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { IsQuantityOptions } from '../../validators/is-quantity.decorator.js';
2
+ import { EnergyUnit } from './energy-unit.enum.js';
3
+ import { Energy } from './energy.js';
4
+ export declare function IsEnergy(options?: IsQuantityOptions<EnergyUnit, Energy>): PropertyDecorator;
@@ -0,0 +1,7 @@
1
+ import { applyDecorators } from '@nestjs/common';
2
+ import { IsQuantity } from '../../validators/is-quantity.decorator.js';
3
+ import { EnergyDto } from './energy.dto.js';
4
+ export function IsEnergy(options) {
5
+ return applyDecorators(IsQuantity(EnergyDto, options));
6
+ }
7
+ //# sourceMappingURL=is-energy.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-energy.validator.js","sourceRoot":"","sources":["../../../lib/quantities/energy/is-energy.validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAqB,MAAM,2CAA2C,CAAA;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C,MAAM,UAAU,QAAQ,CACtB,OAA+C;IAE/C,OAAO,eAAe,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAA;AACxD,CAAC"}
@@ -2,3 +2,4 @@ export * from './mass.js';
2
2
  export * from './mass.dto.js';
3
3
  export * from './mass.column.js';
4
4
  export * from './mass-unit.enum.js';
5
+ export * from './is-mass.validator.js';
@@ -2,4 +2,5 @@ export * from './mass.js';
2
2
  export * from './mass.dto.js';
3
3
  export * from './mass.column.js';
4
4
  export * from './mass-unit.enum.js';
5
+ export * from './is-mass.validator.js';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/mass/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/mass/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { IsQuantityOptions } from '../../validators/is-quantity.decorator.js';
2
+ import { MassUnit } from './mass-unit.enum.js';
3
+ import { Mass } from './mass.js';
4
+ export declare function IsMass(options?: IsQuantityOptions<MassUnit, Mass>): PropertyDecorator;
@@ -0,0 +1,7 @@
1
+ import { applyDecorators } from '@nestjs/common';
2
+ import { IsQuantity } from '../../validators/is-quantity.decorator.js';
3
+ import { MassDto } from './mass.dto.js';
4
+ export function IsMass(options) {
5
+ return applyDecorators(IsQuantity(MassDto, options));
6
+ }
7
+ //# sourceMappingURL=is-mass.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-mass.validator.js","sourceRoot":"","sources":["../../../lib/quantities/mass/is-mass.validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAqB,MAAM,2CAA2C,CAAA;AACzF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAIvC,MAAM,UAAU,MAAM,CACpB,OAA2C;IAE3C,OAAO,eAAe,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;AACtD,CAAC"}
@@ -1,3 +1,4 @@
1
- import { ColumnOptions } from 'typeorm';
1
+ import { QuantityColumnOptions } from '../../quantity.column.js';
2
2
  import { MassUnit } from './mass-unit.enum.js';
3
- export declare function MassColumn(storeAsUnit: MassUnit, options?: Omit<ColumnOptions, 'type' | 'transformer'>): PropertyDecorator;
3
+ import { Mass } from './mass.js';
4
+ export declare function MassColumn(storeAsUnit: MassUnit, options?: QuantityColumnOptions<MassUnit, Mass>): PropertyDecorator;
@@ -1 +1 @@
1
- {"version":3,"file":"mass.column.js","sourceRoot":"","sources":["../../../lib/quantities/mass/mass.column.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,UAAU,CACxB,WAAqB,EACrB,OAAqD;IAErD,OAAO,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACnD,CAAC"}
1
+ {"version":3,"file":"mass.column.js","sourceRoot":"","sources":["../../../lib/quantities/mass/mass.column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAyB,MAAM,0BAA0B,CAAA;AAEhF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,UAAU,CACxB,WAAqB,EACrB,OAA+C;IAE/C,OAAO,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACnD,CAAC"}
@@ -1,6 +1,7 @@
1
+ import { QuantityDto } from '../../quantity.dto.js';
1
2
  import { Mass } from './mass.js';
2
3
  import { MassUnit } from './mass-unit.enum.js';
3
- export declare class MassDto {
4
+ export declare class MassDto extends QuantityDto<Mass> {
4
5
  value: number;
5
6
  unit: MassUnit;
6
7
  static from(mass: undefined): undefined;
@@ -9,9 +9,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { ApiProperty } from '@nestjs/swagger';
11
11
  import { IsEnum, IsNumber } from 'class-validator';
12
+ import { QuantityDto } from '../../quantity.dto.js';
12
13
  import { Mass } from './mass.js';
13
14
  import { MassUnit, MassUnitApiProperty } from './mass-unit.enum.js';
14
- export class MassDto {
15
+ export class MassDto extends QuantityDto {
15
16
  value;
16
17
  unit;
17
18
  static from(mass) {
@@ -1 +1 @@
1
- {"version":3,"file":"mass.dto.js","sourceRoot":"","sources":["../../../lib/quantities/mass/mass.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAEnE,MAAM,OAAO,OAAO;IAGlB,KAAK,CAAQ;IAIb,IAAI,CAAU;IASd,MAAM,CAAC,IAAI,CAAE,IAA6B;QACxC,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;QAC9B,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,SAAS,CAAA;QAExC,O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;IACjB,CAAC;CACF"}
@@ -2,3 +2,4 @@ export * from './power.js';
2
2
  export * from './power.dto.js';
3
3
  export * from './power.column.js';
4
4
  export * from './power-unit.enum.js';
5
+ export * from './is-power.validator.js';
@@ -2,4 +2,5 @@ export * from './power.js';
2
2
  export * from './power.dto.js';
3
3
  export * from './power.column.js';
4
4
  export * from './power-unit.enum.js';
5
+ export * from './is-power.validator.js';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/power/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/power/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { IsQuantityOptions } from '../../validators/is-quantity.decorator.js';
2
+ import { PowerUnit } from './power-unit.enum.js';
3
+ import { Power } from './power.js';
4
+ export declare function IsPower(options?: IsQuantityOptions<PowerUnit, Power>): PropertyDecorator;
@@ -0,0 +1,7 @@
1
+ import { applyDecorators } from '@nestjs/common';
2
+ import { IsQuantity } from '../../validators/is-quantity.decorator.js';
3
+ import { PowerDto } from './power.dto.js';
4
+ export function IsPower(options) {
5
+ return applyDecorators(IsQuantity(PowerDto, options));
6
+ }
7
+ //# sourceMappingURL=is-power.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-power.validator.js","sourceRoot":"","sources":["../../../lib/quantities/power/is-power.validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAqB,MAAM,2CAA2C,CAAA;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAIzC,MAAM,UAAU,OAAO,CACrB,OAA6C;IAE7C,OAAO,eAAe,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;AACvD,CAAC"}
@@ -1,3 +1,4 @@
1
- import { ColumnOptions } from 'typeorm';
1
+ import { QuantityColumnOptions } from '../../quantity.column.js';
2
2
  import { PowerUnit } from './power-unit.enum.js';
3
- export declare function PowerColumn(storeAsUnit: PowerUnit, options?: Omit<ColumnOptions, 'type' | 'transformer'>): PropertyDecorator;
3
+ import { Power } from './power.js';
4
+ export declare function PowerColumn(storeAsUnit: PowerUnit, options?: QuantityColumnOptions<PowerUnit, Power>): PropertyDecorator;
@@ -1 +1 @@
1
- {"version":3,"file":"power.column.js","sourceRoot":"","sources":["../../../lib/quantities/power/power.column.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,MAAM,UAAU,WAAW,CACzB,WAAsB,EACtB,OAAqD;IAErD,OAAO,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACpD,CAAC"}
1
+ {"version":3,"file":"power.column.js","sourceRoot":"","sources":["../../../lib/quantities/power/power.column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAyB,MAAM,0BAA0B,CAAA;AAEhF,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,MAAM,UAAU,WAAW,CACzB,WAAsB,EACtB,OAAiD;IAEjD,OAAO,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACpD,CAAC"}
@@ -2,3 +2,4 @@ export * from './speed.js';
2
2
  export * from './speed.dto.js';
3
3
  export * from './speed.column.js';
4
4
  export * from './speed-unit.enum.js';
5
+ export * from './is-speed.validator.js';
@@ -2,4 +2,5 @@ export * from './speed.js';
2
2
  export * from './speed.dto.js';
3
3
  export * from './speed.column.js';
4
4
  export * from './speed-unit.enum.js';
5
+ export * from './is-speed.validator.js';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/speed/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/speed/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { IsQuantityOptions } from '../../validators/is-quantity.decorator.js';
2
+ import { SpeedUnit } from './speed-unit.enum.js';
3
+ import { Speed } from './speed.js';
4
+ export declare function IsSpeed(options?: IsQuantityOptions<SpeedUnit, Speed>): PropertyDecorator;
@@ -0,0 +1,7 @@
1
+ import { applyDecorators } from '@nestjs/common';
2
+ import { IsQuantity } from '../../validators/is-quantity.decorator.js';
3
+ import { SpeedDto } from './speed.dto.js';
4
+ export function IsSpeed(options) {
5
+ return applyDecorators(IsQuantity(SpeedDto, options));
6
+ }
7
+ //# sourceMappingURL=is-speed.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-speed.validator.js","sourceRoot":"","sources":["../../../lib/quantities/speed/is-speed.validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAqB,MAAM,2CAA2C,CAAA;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAIzC,MAAM,UAAU,OAAO,CACrB,OAA6C;IAE7C,OAAO,eAAe,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;AACvD,CAAC"}
@@ -1,3 +1,4 @@
1
- import { ColumnOptions } from 'typeorm';
1
+ import { QuantityColumnOptions } from '../../quantity.column.js';
2
2
  import { SpeedUnit } from './speed-unit.enum.js';
3
- export declare function SpeedColumn(storeAsUnit: SpeedUnit, options?: Omit<ColumnOptions, 'type' | 'transformer'>): PropertyDecorator;
3
+ import { Speed } from './speed.js';
4
+ export declare function SpeedColumn(storeAsUnit: SpeedUnit, options?: QuantityColumnOptions<SpeedUnit, Speed>): PropertyDecorator;
@@ -1 +1 @@
1
- {"version":3,"file":"speed.column.js","sourceRoot":"","sources":["../../../lib/quantities/speed/speed.column.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,MAAM,UAAU,WAAW,CACzB,WAAsB,EACtB,OAAqD;IAErD,OAAO,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACpD,CAAC"}
1
+ {"version":3,"file":"speed.column.js","sourceRoot":"","sources":["../../../lib/quantities/speed/speed.column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAyB,MAAM,0BAA0B,CAAA;AAEhF,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,MAAM,UAAU,WAAW,CACzB,WAAsB,EACtB,OAAiD;IAEjD,OAAO,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACpD,CAAC"}
@@ -2,3 +2,4 @@ export * from './temperature.js';
2
2
  export * from './temperature.dto.js';
3
3
  export * from './temperature.column.js';
4
4
  export * from './temperature-unit.enum.js';
5
+ export * from './is-temperature.validator.js';
@@ -2,4 +2,5 @@ export * from './temperature.js';
2
2
  export * from './temperature.dto.js';
3
3
  export * from './temperature.column.js';
4
4
  export * from './temperature-unit.enum.js';
5
+ export * from './is-temperature.validator.js';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/temperature/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/temperature/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,+BAA+B,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { IsQuantityOptions } from '../../validators/is-quantity.decorator.js';
2
+ import { TemperatureUnit } from './temperature-unit.enum.js';
3
+ import { Temperature } from './temperature.js';
4
+ export declare function IsTemperature(options?: IsQuantityOptions<TemperatureUnit, Temperature>): PropertyDecorator;
@@ -0,0 +1,7 @@
1
+ import { applyDecorators } from '@nestjs/common';
2
+ import { IsQuantity } from '../../validators/is-quantity.decorator.js';
3
+ import { TemperatureDto } from './temperature.dto.js';
4
+ export function IsTemperature(options) {
5
+ return applyDecorators(IsQuantity(TemperatureDto, options));
6
+ }
7
+ //# sourceMappingURL=is-temperature.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-temperature.validator.js","sourceRoot":"","sources":["../../../lib/quantities/temperature/is-temperature.validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAqB,MAAM,2CAA2C,CAAA;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAIrD,MAAM,UAAU,aAAa,CAC3B,OAAyD;IAEzD,OAAO,eAAe,CAAC,UAAU,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAA;AAC7D,CAAC"}
@@ -1,6 +1,9 @@
1
1
  import { ColumnOptions, ValueTransformer } from 'typeorm';
2
2
  import { Quantity, QuantityConstructor } from './quantity.js';
3
- export declare function QuantityColumn<U extends string, Q extends Quantity<U, Q>>(QuantityConstructor: QuantityConstructor<U, Q>, storeAsUnit: U, options?: Omit<ColumnOptions, 'type' | 'transformer'>): PropertyDecorator;
3
+ export type QuantityColumnOptions<U extends string, Q extends Quantity<U, Q>> = Omit<ColumnOptions, 'type' | 'transformer' | 'default'> & {
4
+ default?: Q;
5
+ };
6
+ export declare function QuantityColumn<U extends string, Q extends Quantity<U, Q>>(QuantityConstructor: QuantityConstructor<U, Q>, storeAsUnit: U, options?: QuantityColumnOptions<U, Q>): PropertyDecorator;
4
7
  export declare class QuantityTypeOrmTransformer<U extends string, Q extends Quantity<U, Q>> implements ValueTransformer {
5
8
  private readonly QuantityConstructor;
6
9
  private readonly storedUnit;
@@ -9,4 +12,5 @@ export declare class QuantityTypeOrmTransformer<U extends string, Q extends Quan
9
12
  from(value: number | null): Q | null;
10
13
  to(quantity: Q): number;
11
14
  to(quantity: Q | null): number | null;
15
+ to(quantity: Q | null | undefined): number | null | undefined;
12
16
  }
@@ -1,9 +1,11 @@
1
1
  import { Column } from 'typeorm';
2
2
  export function QuantityColumn(QuantityConstructor, storeAsUnit, options) {
3
+ const transformer = new QuantityTypeOrmTransformer(QuantityConstructor, storeAsUnit);
3
4
  return Column({
4
5
  ...options,
6
+ default: transformer.to(options?.default),
5
7
  type: 'float',
6
- transformer: new QuantityTypeOrmTransformer(QuantityConstructor, storeAsUnit)
8
+ transformer
7
9
  });
8
10
  }
9
11
  export class QuantityTypeOrmTransformer {
@@ -20,11 +22,8 @@ export class QuantityTypeOrmTransformer {
20
22
  return new this.QuantityConstructor(value, this.storedUnit);
21
23
  }
22
24
  to(quantity) {
23
- if (quantity === null) {
24
- return null;
25
- }
26
- if (quantity === undefined) {
27
- return null;
25
+ if (quantity === undefined || quantity === null) {
26
+ return quantity;
28
27
  }
29
28
  return quantity.asNumber(this.storedUnit);
30
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"quantity.column.js","sourceRoot":"","sources":["../lib/quantity.column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmC,MAAM,SAAS,CAAA;AAGjE,MAAM,UAAU,cAAc,CAC5B,mBAA8C,EAC9C,WAAc,EACd,OAAqD;IAErD,OAAO,MAAM,CAAC;QACZ,GAAG,OAAO;QACV,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,IAAI,0BAA0B,CAAC,mBAAmB,EAAE,WAAW,CAAC;KAC9E,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,OAAO,0BAA0B;IAGlB;IACA;IAFnB,YACmB,mBAA8C,EAC9C,UAAa;QADb,wBAAmB,GAAnB,mBAAmB,CAA2B;QAC9C,eAAU,GAAV,UAAU,CAAG;IAC7B,CAAC;IAIJ,IAAI,CAAE,KAAoB;QACxB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO,IAAI,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;IAC7D,CAAC;IAID,EAAE,CAAE,QAA8B;QAChC,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACtB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC3C,CAAC;CACF"}
1
+ {"version":3,"file":"quantity.column.js","sourceRoot":"","sources":["../lib/quantity.column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmC,MAAM,SAAS,CAAA;AAMjE,MAAM,UAAU,cAAc,CAC5B,mBAA8C,EAC9C,WAAc,EACd,OAAqC;IAErC,MAAM,WAAW,GAAG,IAAI,0BAA0B,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAA;IAEpF,OAAO,MAAM,CAAC;QACZ,GAAG,OAAO;QACV,OAAO,EAAE,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;QACzC,IAAI,EAAE,OAAO;QACb,WAAW;KACZ,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,OAAO,0BAA0B;IAGlB;IACA;IAFnB,YACmB,mBAA8C,EAC9C,UAAa;QADb,wBAAmB,GAAnB,mBAAmB,CAA2B;QAC9C,eAAU,GAAV,UAAU,CAAG;IAC7B,CAAC;IAIJ,IAAI,CAAE,KAAoB;QACxB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO,IAAI,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;IAC7D,CAAC;IAKD,EAAE,CAAE,QAA8B;QAChC,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YAChD,OAAO,QAAQ,CAAA;QACjB,CAAC;QAED,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC3C,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import { Quantity } from './quantity.js';
2
+ export declare abstract class QuantityDto<Q extends Quantity<string, Q>> {
3
+ abstract parse(): Q;
4
+ }
@@ -0,0 +1,3 @@
1
+ export class QuantityDto {
2
+ }
3
+ //# sourceMappingURL=quantity.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quantity.dto.js","sourceRoot":"","sources":["../lib/quantity.dto.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,WAAW;CAEhC"}
@@ -0,0 +1,9 @@
1
+ import { ClassConstructor } from 'class-transformer';
2
+ import { ValidationOptions } from 'class-validator';
3
+ import { Quantity } from '../quantity.js';
4
+ import { QuantityDto } from '../quantity.dto.js';
5
+ export interface IsQuantityOptions<U extends string, Q extends Quantity<U, Q>> extends ValidationOptions {
6
+ min?: Q;
7
+ max?: Q;
8
+ }
9
+ export declare function IsQuantity<U extends string, Q extends Quantity<U, Q>>(quantityClass: ClassConstructor<QuantityDto<Q>>, options?: IsQuantityOptions<U, Q>): PropertyDecorator;
@@ -0,0 +1,22 @@
1
+ import { Type } from 'class-transformer';
2
+ import { applyDecorators } from '@nestjs/common';
3
+ import { IsObject, ValidateBy, ValidateNested } from 'class-validator';
4
+ import { MinQuantityValidator } from './min-quantity.validator.js';
5
+ import { MaxQuantityValidator } from './max-quantity.validator.js';
6
+ export function IsQuantity(quantityClass, options) {
7
+ const decorators = [
8
+ Type(() => quantityClass),
9
+ ValidateNested(options),
10
+ IsObject(options)
11
+ ];
12
+ if (options?.min !== undefined) {
13
+ const validator = new MinQuantityValidator(options.min);
14
+ decorators.push(ValidateBy({ name: 'minQuantityValidator', validator }));
15
+ }
16
+ if (options?.max !== undefined) {
17
+ const validator = new MaxQuantityValidator(options.max);
18
+ decorators.push(ValidateBy({ name: 'maxQuantityValidator', validator }));
19
+ }
20
+ return applyDecorators(...decorators);
21
+ }
22
+ //# sourceMappingURL=is-quantity.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-quantity.decorator.js","sourceRoot":"","sources":["../../lib/validators/is-quantity.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAqB,MAAM,iBAAiB,CAAA;AAGzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAQlE,MAAM,UAAU,UAAU,CACxB,aAA+C,EAC/C,OAAiC;IAEjC,MAAM,UAAU,GAAG;QACjB,IAAI,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC;QACzB,cAAc,CAAC,OAAO,CAAC;QACvB,QAAQ,CAAC,OAAO,CAAC;KAClB,CAAA;IAED,IAAI,OAAO,EAAE,GAAG,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAEvD,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;IAC1E,CAAC;IAED,IAAI,OAAO,EAAE,GAAG,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAEvD,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;IAC1E,CAAC;IAED,OAAO,eAAe,CAAC,GAAG,UAAU,CAAC,CAAA;AACvC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { ValidatorConstraintInterface, ValidationArguments } from 'class-validator';
2
+ import { Quantity } from '../quantity.js';
3
+ export declare class MaxQuantityValidator<U extends string, Q extends Quantity<U, Q>> implements ValidatorConstraintInterface {
4
+ private max;
5
+ constructor(max: Q);
6
+ validate(q: unknown, _args: ValidationArguments): boolean;
7
+ defaultMessage(args: ValidationArguments): string;
8
+ }
@@ -0,0 +1,18 @@
1
+ import { QuantityDto } from '../quantity.dto.js';
2
+ export class MaxQuantityValidator {
3
+ max;
4
+ constructor(max) {
5
+ this.max = max;
6
+ }
7
+ validate(q, _args) {
8
+ if (!(q instanceof QuantityDto)) {
9
+ return false;
10
+ }
11
+ const value = q.parse();
12
+ return this.max.isMoreThanOrEqualTo(value);
13
+ }
14
+ defaultMessage(args) {
15
+ return `${args.property} must be <= ${this.max.toString()}`;
16
+ }
17
+ }
18
+ //# sourceMappingURL=max-quantity.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max-quantity.validator.js","sourceRoot":"","sources":["../../lib/validators/max-quantity.validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGhD,MAAM,OAAO,oBAAoB;IAGrB;IADV,YACU,GAAM;QAAN,QAAG,GAAH,GAAG,CAAG;IACb,CAAC;IAEJ,QAAQ,CAAE,CAAU,EAAE,KAA0B;QAC9C,IAAI,CAAC,CAAC,CAAC,YAAY,WAAW,CAAC,EAAE,CAAC;YAChC,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,EAAO,CAAA;QAE5B,OAAO,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAC5C,CAAC;IAED,cAAc,CAAE,IAAyB;QACvC,OAAO,GAAG,IAAI,CAAC,QAAQ,eAAe,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAA;IAC7D,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import { ValidatorConstraintInterface, ValidationArguments } from 'class-validator';
2
+ import { Quantity } from '../quantity.js';
3
+ export declare class MinQuantityValidator<U extends string, Q extends Quantity<U, Q>> implements ValidatorConstraintInterface {
4
+ private min;
5
+ constructor(min: Q);
6
+ validate(q: unknown, _args: ValidationArguments): boolean;
7
+ defaultMessage(args: ValidationArguments): string;
8
+ }
@@ -0,0 +1,18 @@
1
+ import { QuantityDto } from '../quantity.dto.js';
2
+ export class MinQuantityValidator {
3
+ min;
4
+ constructor(min) {
5
+ this.min = min;
6
+ }
7
+ validate(q, _args) {
8
+ if (!(q instanceof QuantityDto)) {
9
+ return false;
10
+ }
11
+ const value = q.parse();
12
+ return this.min.isLessThanOrEqualTo(value);
13
+ }
14
+ defaultMessage(args) {
15
+ return `${args.property} must be >= ${this.min.toString()}`;
16
+ }
17
+ }
18
+ //# sourceMappingURL=min-quantity.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"min-quantity.validator.js","sourceRoot":"","sources":["../../lib/validators/min-quantity.validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGhD,MAAM,OAAO,oBAAoB;IAGrB;IADV,YACU,GAAM;QAAN,QAAG,GAAH,GAAG,CAAG;IACb,CAAC;IAEJ,QAAQ,CAAE,CAAU,EAAE,KAA0B;QAC9C,IAAI,CAAC,CAAC,CAAC,YAAY,WAAW,CAAC,EAAE,CAAC;YAChC,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,EAAO,CAAA;QAE5B,OAAO,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAC5C,CAAC;IAED,cAAc,CAAE,IAAyB;QACvC,OAAO,GAAG,IAAI,CAAC,QAAQ,eAAe,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAA;IAC7D,CAAC;CACF"}
@@ -0,0 +1,170 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { describe, it } from 'node:test';
11
+ import { plainToInstance } from 'class-transformer';
12
+ import { validate } from 'class-validator';
13
+ import { expect } from 'expect';
14
+ import { Distance } from '../../quantities/distance/distance.js';
15
+ import { DistanceUnit } from '../../quantities/distance/distance-unit.enum.js';
16
+ import { DistanceDto } from '../../quantities/distance/distance.dto.js';
17
+ import { IsQuantity } from '../is-quantity.decorator.js';
18
+ describe('is quantity decorator tests', () => {
19
+ describe('min option', () => {
20
+ class MinDistanceTestDto {
21
+ distance;
22
+ }
23
+ __decorate([
24
+ IsQuantity(DistanceDto, { min: new Distance(10, DistanceUnit.METER) }),
25
+ __metadata("design:type", DistanceDto)
26
+ ], MinDistanceTestDto.prototype, "distance", void 0);
27
+ it('detects validation errors when the distance is less than the minimum', async () => {
28
+ const dto = plainToInstance(MinDistanceTestDto, { distance: {
29
+ value: 5,
30
+ unit: DistanceUnit.METER
31
+ } });
32
+ const errors = await validate(dto);
33
+ expect(errors.length).toBeGreaterThan(0);
34
+ });
35
+ it('passes a distance exactly at the minimum', async () => {
36
+ const dto = plainToInstance(MinDistanceTestDto, { distance: {
37
+ value: 10,
38
+ unit: DistanceUnit.METER
39
+ } });
40
+ const errors = await validate(dto);
41
+ expect(errors).toHaveLength(0);
42
+ });
43
+ it('passes a distance above the minimum', async () => {
44
+ const dto = plainToInstance(MinDistanceTestDto, { distance: {
45
+ value: 20,
46
+ unit: DistanceUnit.METER
47
+ } });
48
+ const errors = await validate(dto);
49
+ expect(errors).toHaveLength(0);
50
+ });
51
+ it('passes a distance above the minimum expressed in a different unit', async () => {
52
+ const dto = plainToInstance(MinDistanceTestDto, { distance: {
53
+ value: 0.02,
54
+ unit: DistanceUnit.KILOMETER
55
+ } });
56
+ const errors = await validate(dto);
57
+ expect(errors).toHaveLength(0);
58
+ });
59
+ it('detects validation errors when the distance is less than the minimum expressed in a different unit', async () => {
60
+ const dto = plainToInstance(MinDistanceTestDto, { distance: {
61
+ value: 0.005,
62
+ unit: DistanceUnit.KILOMETER
63
+ } });
64
+ const errors = await validate(dto);
65
+ expect(errors.length).toBeGreaterThan(0);
66
+ });
67
+ });
68
+ describe('max option', () => {
69
+ class MaxDistanceTestDto {
70
+ distance;
71
+ }
72
+ __decorate([
73
+ IsQuantity(DistanceDto, { max: new Distance(100, DistanceUnit.METER) }),
74
+ __metadata("design:type", DistanceDto)
75
+ ], MaxDistanceTestDto.prototype, "distance", void 0);
76
+ it('detects validation errors when the distance exceeds the maximum', async () => {
77
+ const dto = plainToInstance(MaxDistanceTestDto, { distance: {
78
+ value: 150,
79
+ unit: DistanceUnit.METER
80
+ } });
81
+ const errors = await validate(dto);
82
+ expect(errors.length).toBeGreaterThan(0);
83
+ });
84
+ it('passes a distance exactly at the maximum', async () => {
85
+ const dto = plainToInstance(MaxDistanceTestDto, { distance: {
86
+ value: 100,
87
+ unit: DistanceUnit.METER
88
+ } });
89
+ const errors = await validate(dto);
90
+ expect(errors).toHaveLength(0);
91
+ });
92
+ it('passes a distance below the maximum', async () => {
93
+ const dto = plainToInstance(MaxDistanceTestDto, { distance: {
94
+ value: 50,
95
+ unit: DistanceUnit.METER
96
+ } });
97
+ const errors = await validate(dto);
98
+ expect(errors).toHaveLength(0);
99
+ });
100
+ it('passes a distance below the maximum expressed in a different unit', async () => {
101
+ const dto = plainToInstance(MaxDistanceTestDto, { distance: {
102
+ value: 0.05,
103
+ unit: DistanceUnit.KILOMETER
104
+ } });
105
+ const errors = await validate(dto);
106
+ expect(errors).toHaveLength(0);
107
+ });
108
+ it('detects validation errors when the distance exceeds the maximum expressed in a different unit', async () => {
109
+ const dto = plainToInstance(MaxDistanceTestDto, { distance: {
110
+ value: 0.2,
111
+ unit: DistanceUnit.KILOMETER
112
+ } });
113
+ const errors = await validate(dto);
114
+ expect(errors.length).toBeGreaterThan(0);
115
+ });
116
+ });
117
+ describe('min and max options together', () => {
118
+ class MinMaxDistanceTestDto {
119
+ distance;
120
+ }
121
+ __decorate([
122
+ IsQuantity(DistanceDto, {
123
+ min: new Distance(10, DistanceUnit.METER),
124
+ max: new Distance(100, DistanceUnit.METER)
125
+ }),
126
+ __metadata("design:type", DistanceDto)
127
+ ], MinMaxDistanceTestDto.prototype, "distance", void 0);
128
+ it('detects validation errors when the distance is below the minimum', async () => {
129
+ const dto = plainToInstance(MinMaxDistanceTestDto, { distance: {
130
+ value: 5,
131
+ unit: DistanceUnit.METER
132
+ } });
133
+ const errors = await validate(dto);
134
+ expect(errors.length).toBeGreaterThan(0);
135
+ });
136
+ it('detects validation errors when the distance exceeds the maximum', async () => {
137
+ const dto = plainToInstance(MinMaxDistanceTestDto, { distance: {
138
+ value: 150,
139
+ unit: DistanceUnit.METER
140
+ } });
141
+ const errors = await validate(dto);
142
+ expect(errors.length).toBeGreaterThan(0);
143
+ });
144
+ it('passes a distance within the range', async () => {
145
+ const dto = plainToInstance(MinMaxDistanceTestDto, { distance: {
146
+ value: 50,
147
+ unit: DistanceUnit.METER
148
+ } });
149
+ const errors = await validate(dto);
150
+ expect(errors).toHaveLength(0);
151
+ });
152
+ it('passes a distance at the minimum boundary', async () => {
153
+ const dto = plainToInstance(MinMaxDistanceTestDto, { distance: {
154
+ value: 10,
155
+ unit: DistanceUnit.METER
156
+ } });
157
+ const errors = await validate(dto);
158
+ expect(errors).toHaveLength(0);
159
+ });
160
+ it('passes a distance at the maximum boundary', async () => {
161
+ const dto = plainToInstance(MinMaxDistanceTestDto, { distance: {
162
+ value: 100,
163
+ unit: DistanceUnit.METER
164
+ } });
165
+ const errors = await validate(dto);
166
+ expect(errors).toHaveLength(0);
167
+ });
168
+ });
169
+ });
170
+ //# sourceMappingURL=is-quantity.decorator.unit.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-quantity.decorator.unit.test.js","sourceRoot":"","sources":["../../../lib/validators/tests/is-quantity.decorator.unit.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD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,CAAA;YAEJ,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAA;YAElC,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QAChC,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;YACzD,MAAM,GAAG,GAAG,eAAe,CAAC,qBAAqB,EAAE,EAAE,QAAQ,EAAE;oBAC7D,KAAK,EAAE,GAAG;oBACV,IAAI,EAAE,YAAY,CAAC,KAAK;iBACzB,EAAE,CAAC,CAAA;YAEJ,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAA;YAElC,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QAChC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,40 +1,45 @@
1
1
  {
2
2
  "name": "@wisemen/quantity",
3
- "version": "0.3.6",
3
+ "version": "0.4.1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "main": "./dist/index.js",
5
8
  "types": "./dist/index.d.ts",
6
9
  "type": "module",
7
10
  "files": [
8
11
  "dist/"
9
12
  ],
10
- "scripts": {
11
- "prebuild": "rm -rf ./dist",
12
- "clean": "rm -rf ./dist",
13
- "build": "tsc",
14
- "pretest": "npm run clean && npm run build",
15
- "test": "node --test ./dist/**/*.test.js",
16
- "lint": "eslint --cache",
17
- "prerelease": "npm run build",
18
- "release": "pnpx release-it"
19
- },
20
13
  "peerDependencies": {
21
- "@nestjs/common": "^11.1.13",
22
- "@nestjs/swagger": "^11.2.6",
23
- "@wisemen/nestjs-typeorm": "^0.1.3",
24
- "class-transformer": "^0.5.1",
25
- "class-validator": "^0.14.3",
26
- "typeorm": "^0.3.28"
14
+ "@nestjs/common": ">=11.1.17",
15
+ "@nestjs/swagger": ">=11.2.6",
16
+ "class-transformer": ">=0.5.1",
17
+ "class-validator": ">=0.14.3",
18
+ "typeorm": ">=0.3.28"
27
19
  },
28
20
  "devDependencies": {
29
- "@wisemen/eslint-config-nestjs": "^0.2.8",
30
- "eslint": "^9.39.2",
31
- "expect": "^30.2.0",
32
- "typescript": "^5.9.3"
21
+ "eslint": "9.39.4",
22
+ "expect": "30.2.0",
23
+ "typescript": ">=4.8.4 <=5.9.3",
24
+ "@wisemen/eslint-config-nestjs": "0.2.12"
33
25
  },
34
26
  "author": "Maarten Sijmkens",
35
27
  "license": "GPL",
36
28
  "repository": {
37
29
  "type": "git",
38
- "url": "git@github.com:wisemen-digital/node-core.git"
30
+ "url": "https://github.com/wisemen-digital/wisemen-core",
31
+ "directory": "packages/quantity"
32
+ },
33
+ "dependencies": {
34
+ "@wisemen/nestjs-typeorm": "0.2.0"
35
+ },
36
+ "scripts": {
37
+ "clean": "rm -rf ./dist",
38
+ "build": "tsc",
39
+ "pretest": "pnpm run build",
40
+ "test": "node --test './dist/**/*.test.js'",
41
+ "lint": "eslint --cache",
42
+ "prerelease": "npm run build",
43
+ "release": "pnpx release-it"
39
44
  }
40
- }
45
+ }