pwi-plata-type 0.1.5 → 0.1.6

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 (2) hide show
  1. package/libs/model.ts +6 -13
  2. package/package.json +1 -1
package/libs/model.ts CHANGED
@@ -92,7 +92,6 @@ export function _filtraModel(value: any, model: Model): any {
92
92
 
93
93
  export async function _validaModel(value: any, model: Model, name?: string): Promise<ErroValidacao[]> {
94
94
  let promises: any[] = []
95
- let errors: ErroValidacao[] = []
96
95
 
97
96
  for(const campo in model.template) {
98
97
  const t = model.template[campo]
@@ -140,15 +139,11 @@ export async function _validaModel(value: any, model: Model, name?: string): Pro
140
139
  )
141
140
 
142
141
  if ((Erros as any).errorID !== undefined) {
143
- errors.push(Erros as ErroValidacao)
144
-
145
- return errors
142
+ return Erros as ErroValidacao[]
146
143
  }
147
144
 
148
- errors = errors.concat(Erros)
149
-
150
- if (errors.length !== 0) {
151
- return errors
145
+ if ((Erros as any[]).length !== 0) {
146
+ return Erros as ErroValidacao[]
152
147
  }
153
148
 
154
149
  promises = []
@@ -158,7 +153,7 @@ export async function _validaModel(value: any, model: Model, name?: string): Pro
158
153
  }
159
154
 
160
155
  Erros = await Promise.all(promises).then(
161
- result => [].concat(...result),
156
+ result => [].concat(...result).filter(v => v !== null),
162
157
  err => {
163
158
  return {
164
159
  errorID: 'BPLM0003',
@@ -169,12 +164,10 @@ export async function _validaModel(value: any, model: Model, name?: string): Pro
169
164
  )
170
165
 
171
166
  if ((Erros as any).errorID !== undefined) {
172
- errors.push(Erros as ErroValidacao)
173
-
174
- return errors
167
+ return Erros as ErroValidacao[]
175
168
  }
176
169
 
177
- return errors.concat(Erros)
170
+ return Erros as ErroValidacao[]
178
171
  }
179
172
 
180
173
  export async function valida(value: any, model: Model): Promise<RetornoValicadaoModel> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pwi-plata-type",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "bin": {