pwi-plata-type 0.1.4 → 0.1.7
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/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]
|
|
@@ -100,7 +99,7 @@ export async function _validaModel(value: any, model: Model, name?: string): Pro
|
|
|
100
99
|
if (t.length === undefined) {
|
|
101
100
|
const m = new Model(t as ModelType)
|
|
102
101
|
|
|
103
|
-
promises.push(_validaModel(value[campo], m, `${campo}.`))
|
|
102
|
+
promises.push(_validaModel(value[campo], m, `${name ?? ''}${campo}.`))
|
|
104
103
|
continue
|
|
105
104
|
}
|
|
106
105
|
|
|
@@ -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
|
-
|
|
144
|
-
|
|
145
|
-
return errors
|
|
142
|
+
return Erros as ErroValidacao[]
|
|
146
143
|
}
|
|
147
144
|
|
|
148
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
return errors
|
|
167
|
+
return Erros as ErroValidacao[]
|
|
175
168
|
}
|
|
176
169
|
|
|
177
|
-
return
|
|
170
|
+
return Erros as ErroValidacao[]
|
|
178
171
|
}
|
|
179
172
|
|
|
180
173
|
export async function valida(value: any, model: Model): Promise<RetornoValicadaoModel> {
|
|
@@ -463,7 +456,7 @@ export function VarChar(size: number): ModelValicacaoPrimitivo {
|
|
|
463
456
|
return {
|
|
464
457
|
error: {
|
|
465
458
|
errorID: "BPVVARC001",
|
|
466
|
-
msg: `O campo ${nome} tem que menos de ${
|
|
459
|
+
msg: `O campo ${nome} tem que menos de ${size} caracteres`
|
|
467
460
|
},
|
|
468
461
|
continua: false
|
|
469
462
|
}
|
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -18,7 +18,7 @@ const main = async () => {
|
|
|
18
18
|
|
|
19
19
|
const templateDir = path.join(templatesDir, projectPackageJson.plata_type)
|
|
20
20
|
|
|
21
|
-
const { install } = await import(path.join(templateDir, '_install.mjs'))
|
|
21
|
+
const { install } = await import(`file://${path.join(templateDir, '_install.mjs')}`)
|
|
22
22
|
|
|
23
23
|
projectPackageJson = await install({
|
|
24
24
|
dirs: {
|