@openbox/shared-types 0.1.26 → 0.1.27

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openbox/shared-types",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "Shared Types for Openbox Cloud. ",
5
5
  "types": "src/index.ts",
6
6
  "author": "Openbox Development Team",
package/src/interfaces.ts CHANGED
@@ -1,36 +1,9 @@
1
- import { Transform } from 'class-transformer'
2
- import { IsBoolean, IsInt, IsOptional } from 'class-validator'
3
- import { validationMessage } from './tools'
4
-
5
1
  export class IFilter {
6
- @IsOptional()
7
- @IsInt()
8
- @Transform(({ value }) => parseInt(value))
9
2
  limit?: number
10
-
11
- @IsOptional()
12
- @IsInt()
13
- @Transform(({ value }) => parseInt(value))
14
3
  page?: number
15
-
16
- @IsOptional()
17
4
  search?: string
18
-
19
- @IsOptional()
20
5
  prop?: string
21
-
22
- @IsOptional()
23
6
  order?: string
24
-
25
- @IsOptional()
26
- @Transform(({ value }) =>
27
- value.toLowerCase() === 'true'
28
- ? true
29
- : value.toLowerCase() == 'false'
30
- ? false
31
- : 1
32
- )
33
- @IsBoolean({ message: validationMessage('active', 'IsBoolean') })
34
7
  active?: boolean
35
8
  }
36
9
 
@@ -1,44 +1,7 @@
1
- import { BadRequestException } from '@nestjs/common'
2
- import { Transform } from 'class-transformer'
3
- import {
4
- ArrayNotEmpty,
5
- IsArray,
6
- IsDecimal,
7
- IsInt,
8
- IsOptional,
9
- } from 'class-validator'
10
1
  import { IFilter } from '../../interfaces'
11
- import { validationMessage } from '../../tools'
12
2
 
13
3
  export class GetServicesRequest extends IFilter {
14
- @IsOptional()
15
- @Transform(({ value }) => {
16
- try {
17
- return JSON.parse(value).map((v: string) => parseInt(v))
18
- } catch (error) {
19
- throw new BadRequestException(
20
- 'El elemento enviado no corresponde a un arreglo de numeros.'
21
- )
22
- }
23
- })
24
- @IsArray({ message: validationMessage('types', 'IsArray') })
25
- @ArrayNotEmpty({ message: validationMessage('types', 'ArrayNotEmpty') })
26
- @IsInt({ each: true, message: validationMessage('types', 'IsInt') })
27
4
  types?: number[]
28
-
29
- @IsOptional()
30
- @Transform(({ value }) => parseFloat(value).toFixed(2))
31
- @IsDecimal(
32
- { decimal_digits: '2' },
33
- { message: validationMessage('fromAmount', 'IsDecimal') }
34
- )
35
5
  fromAmount?: number
36
-
37
- @IsOptional()
38
- @Transform(({ value }) => parseFloat(value).toFixed(2))
39
- @IsDecimal(
40
- { decimal_digits: '2' },
41
- { message: validationMessage('toAmount', 'IsDecimal') }
42
- )
43
6
  toAmount?: number
44
7
  }