@77sol-lab/form-schemas 1.5.1 → 1.6.0
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/{chunk-P54HBDOE.mjs → chunk-2ZKUSLGU.mjs} +2 -2
- package/{chunk-OX3X37VR.mjs → chunk-35IKZUF4.mjs} +2 -2
- package/{chunk-VGFPONIS.mjs → chunk-57DSP6GG.mjs} +1 -1
- package/{chunk-Y3FAMPYF.mjs → chunk-5YFVPFSM.mjs} +61 -21
- package/{chunk-2CN56LSL.mjs → chunk-66Y3FO5R.mjs} +2 -2
- package/{chunk-WRJAOYL6.mjs → chunk-ACJUTGEC.mjs} +1 -1
- package/{chunk-YNVJAGAY.mjs → chunk-AQ43O5UO.mjs} +41 -33
- package/{chunk-7ZERTOE7.mjs → chunk-BITN6YDR.mjs} +2 -2
- package/{chunk-6TFRV3FG.mjs → chunk-BRBOOPFN.mjs} +2 -2
- package/{chunk-3BPZV6IW.mjs → chunk-BSG5DCL7.mjs} +1 -1
- package/{chunk-XII4F5RZ.mjs → chunk-CSGG5DZE.mjs} +1 -1
- package/{chunk-AURTWOTB.mjs → chunk-E7JXDCBO.mjs} +2 -2
- package/{chunk-O7OHCS36.mjs → chunk-GVOOT43S.mjs} +1 -1
- package/{chunk-OMDC46YE.mjs → chunk-ISJKYUMR.mjs} +2 -2
- package/{chunk-6HBDXEIK.mjs → chunk-JBTU6WKN.mjs} +2 -2
- package/{chunk-HHJNVLHK.mjs → chunk-K23FTEKB.mjs} +1 -1
- package/{chunk-FT5BAKSG.mjs → chunk-LEUH6IFB.mjs} +2 -2
- package/{chunk-2W3LQ75V.mjs → chunk-LOEAPRSO.mjs} +2 -2
- package/{chunk-THYAK7O3.mjs → chunk-LVFKP46R.mjs} +2 -2
- package/{chunk-3RSZ4NGE.mjs → chunk-O5XQR5HN.mjs} +1 -1
- package/{chunk-F76ICRGY.mjs → chunk-OFCVHF6Z.mjs} +2 -2
- package/{chunk-DERWNSPY.mjs → chunk-PY7IUNIU.mjs} +1 -1
- package/{chunk-JPFAMQGV.mjs → chunk-QUBWDT4D.mjs} +1 -1
- package/{chunk-WGPPH7DC.mjs → chunk-RDLOQ6HV.mjs} +1 -1
- package/{chunk-HZM2PWYJ.mjs → chunk-SKSUT6CG.mjs} +2 -2
- package/{chunk-GR2PK3Z7.mjs → chunk-T2MFLA6J.mjs} +2 -2
- package/{chunk-WPLLR3SO.mjs → chunk-UYCCHEM5.mjs} +2 -2
- package/{chunk-MDK5KVJT.mjs → chunk-W6J3SW2H.mjs} +2 -2
- package/{chunk-3O52U22S.mjs → chunk-WPJOW7IE.mjs} +2 -2
- package/{chunk-OUVNM2RX.mjs → chunk-X4LHQVVJ.mjs} +1 -1
- package/{chunk-YQJCILG3.mjs → chunk-XVITSWCY.mjs} +1 -1
- package/{chunk-2YVK6IDS.mjs → chunk-Y7TQ2NQ2.mjs} +3 -3
- package/{chunk-PO6GQE6E.mjs → chunk-ZQ2PKLTM.mjs} +2 -2
- package/financing/formalization/index.d.cts +867 -0
- package/financing/formalization/index.d.ts +867 -0
- package/financing/formalization/index.js +68 -22
- package/financing/formalization/index.mjs +33 -33
- package/financing/formalization/schemas/AlfaPFSchema.d.cts +8 -0
- package/financing/formalization/schemas/AlfaPFSchema.d.ts +8 -0
- package/financing/formalization/schemas/AlfaPFSchema.js +51 -20
- package/financing/formalization/schemas/AlfaPFSchema.mjs +3 -3
- package/financing/formalization/schemas/AlfaPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/AlfaPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/AlfaPJSchema.js +51 -20
- package/financing/formalization/schemas/AlfaPJSchema.mjs +2 -2
- package/financing/formalization/schemas/BancoDoBrasilPFSchema.d.cts +8 -0
- package/financing/formalization/schemas/BancoDoBrasilPFSchema.d.ts +8 -0
- package/financing/formalization/schemas/BancoDoBrasilPFSchema.js +51 -20
- package/financing/formalization/schemas/BancoDoBrasilPFSchema.mjs +3 -3
- package/financing/formalization/schemas/BancoDoBrasilPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/BancoDoBrasilPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/BancoDoBrasilPJSchema.js +51 -20
- package/financing/formalization/schemas/BancoDoBrasilPJSchema.mjs +2 -2
- package/financing/formalization/schemas/BtgPFSchema.d.cts +8 -0
- package/financing/formalization/schemas/BtgPFSchema.d.ts +8 -0
- package/financing/formalization/schemas/BtgPFSchema.js +51 -20
- package/financing/formalization/schemas/BtgPFSchema.mjs +3 -3
- package/financing/formalization/schemas/BtgPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/BtgPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/BtgPJSchema.js +51 -20
- package/financing/formalization/schemas/BtgPJSchema.mjs +3 -3
- package/financing/formalization/schemas/BvPFSchema.d.cts +8 -0
- package/financing/formalization/schemas/BvPFSchema.d.ts +8 -0
- package/financing/formalization/schemas/BvPFSchema.js +51 -20
- package/financing/formalization/schemas/BvPFSchema.mjs +3 -3
- package/financing/formalization/schemas/BvPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/BvPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/BvPJSchema.js +51 -20
- package/financing/formalization/schemas/BvPJSchema.mjs +3 -3
- package/financing/formalization/schemas/CaixaEconomicaFederalPFSchema.d.cts +8 -0
- package/financing/formalization/schemas/CaixaEconomicaFederalPFSchema.d.ts +8 -0
- package/financing/formalization/schemas/CaixaEconomicaFederalPFSchema.js +51 -20
- package/financing/formalization/schemas/CaixaEconomicaFederalPFSchema.mjs +3 -3
- package/financing/formalization/schemas/CaixaEconomicaFederalPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/CaixaEconomicaFederalPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/CaixaEconomicaFederalPJSchema.js +51 -20
- package/financing/formalization/schemas/CaixaEconomicaFederalPJSchema.mjs +2 -2
- package/financing/formalization/schemas/CashMePFSchema.d.cts +8 -0
- package/financing/formalization/schemas/CashMePFSchema.d.ts +8 -0
- package/financing/formalization/schemas/CashMePFSchema.js +51 -20
- package/financing/formalization/schemas/CashMePFSchema.mjs +3 -3
- package/financing/formalization/schemas/CashMePJSchema.d.cts +8 -0
- package/financing/formalization/schemas/CashMePJSchema.d.ts +8 -0
- package/financing/formalization/schemas/CashMePJSchema.js +51 -20
- package/financing/formalization/schemas/CashMePJSchema.mjs +2 -2
- package/financing/formalization/schemas/Credito77PFSchema.d.cts +8 -0
- package/financing/formalization/schemas/Credito77PFSchema.d.ts +8 -0
- package/financing/formalization/schemas/Credito77PFSchema.js +51 -20
- package/financing/formalization/schemas/Credito77PFSchema.mjs +3 -3
- package/financing/formalization/schemas/Credito77PJSchema.d.cts +8 -0
- package/financing/formalization/schemas/Credito77PJSchema.d.ts +8 -0
- package/financing/formalization/schemas/Credito77PJSchema.js +51 -20
- package/financing/formalization/schemas/Credito77PJSchema.mjs +2 -2
- package/financing/formalization/schemas/EosPFSchema.d.cts +8 -0
- package/financing/formalization/schemas/EosPFSchema.d.ts +8 -0
- package/financing/formalization/schemas/EosPFSchema.js +51 -20
- package/financing/formalization/schemas/EosPFSchema.mjs +3 -3
- package/financing/formalization/schemas/EosPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/EosPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/EosPJSchema.js +51 -20
- package/financing/formalization/schemas/EosPJSchema.mjs +2 -2
- package/financing/formalization/schemas/HdtEnergyPFSchema.d.cts +8 -0
- package/financing/formalization/schemas/HdtEnergyPFSchema.d.ts +8 -0
- package/financing/formalization/schemas/HdtEnergyPFSchema.js +51 -20
- package/financing/formalization/schemas/HdtEnergyPFSchema.mjs +3 -3
- package/financing/formalization/schemas/HdtEnergyPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/HdtEnergyPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/HdtEnergyPJSchema.js +51 -20
- package/financing/formalization/schemas/HdtEnergyPJSchema.mjs +2 -2
- package/financing/formalization/schemas/LosangoPFSchema.d.cts +8 -0
- package/financing/formalization/schemas/LosangoPFSchema.d.ts +8 -0
- package/financing/formalization/schemas/LosangoPFSchema.js +51 -20
- package/financing/formalization/schemas/LosangoPFSchema.mjs +3 -3
- package/financing/formalization/schemas/LosangoPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/LosangoPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/LosangoPJSchema.js +51 -20
- package/financing/formalization/schemas/LosangoPJSchema.mjs +2 -2
- package/financing/formalization/schemas/SafraPFSchema.d.cts +8 -0
- package/financing/formalization/schemas/SafraPFSchema.d.ts +8 -0
- package/financing/formalization/schemas/SafraPFSchema.js +51 -20
- package/financing/formalization/schemas/SafraPFSchema.mjs +3 -3
- package/financing/formalization/schemas/SafraPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/SafraPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/SafraPJSchema.js +51 -20
- package/financing/formalization/schemas/SafraPJSchema.mjs +2 -2
- package/financing/formalization/schemas/SantanderPFSchema.d.cts +8 -0
- package/financing/formalization/schemas/SantanderPFSchema.d.ts +8 -0
- package/financing/formalization/schemas/SantanderPFSchema.js +51 -20
- package/financing/formalization/schemas/SantanderPFSchema.mjs +3 -3
- package/financing/formalization/schemas/SantanderPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/SantanderPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/SantanderPJSchema.js +51 -20
- package/financing/formalization/schemas/SantanderPJSchema.mjs +2 -2
- package/financing/formalization/schemas/SolAgoraPFSchema.d.cts +8 -0
- package/financing/formalization/schemas/SolAgoraPFSchema.d.ts +8 -0
- package/financing/formalization/schemas/SolAgoraPFSchema.js +51 -20
- package/financing/formalization/schemas/SolAgoraPFSchema.mjs +3 -3
- package/financing/formalization/schemas/SolAgoraPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/SolAgoraPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/SolAgoraPJSchema.js +51 -20
- package/financing/formalization/schemas/SolAgoraPJSchema.mjs +3 -3
- package/financing/formalization/schemas/SolfacilPFSchema.d.cts +8 -0
- package/financing/formalization/schemas/SolfacilPFSchema.d.ts +8 -0
- package/financing/formalization/schemas/SolfacilPFSchema.js +51 -20
- package/financing/formalization/schemas/SolfacilPFSchema.mjs +3 -3
- package/financing/formalization/schemas/SolfacilPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/SolfacilPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/SolfacilPJSchema.js +51 -20
- package/financing/formalization/schemas/SolfacilPJSchema.mjs +2 -2
- package/financing/formalization/schemas/UnifiedPFSchema.d.cts +10 -2
- package/financing/formalization/schemas/UnifiedPFSchema.d.ts +10 -2
- package/financing/formalization/schemas/UnifiedPFSchema.js +52 -21
- package/financing/formalization/schemas/UnifiedPFSchema.mjs +3 -3
- package/financing/formalization/schemas/UnifiedPJSchema.d.cts +8 -0
- package/financing/formalization/schemas/UnifiedPJSchema.d.ts +8 -0
- package/financing/formalization/schemas/UnifiedPJSchema.js +51 -20
- package/financing/formalization/schemas/UnifiedPJSchema.mjs +3 -3
- package/index.js +68 -22
- package/index.mjs +33 -33
- package/package.json +1 -1
|
@@ -4,12 +4,19 @@ var zod = require('zod');
|
|
|
4
4
|
|
|
5
5
|
// src/domains/financing/formalization/schemas/UnifiedPFSchema.ts
|
|
6
6
|
var REQUIRED_MESSAGE = "Campo obrigat\xF3rio";
|
|
7
|
+
var REQUIRED_STRING_PARAMS = {
|
|
8
|
+
required_error: REQUIRED_MESSAGE,
|
|
9
|
+
invalid_type_error: REQUIRED_MESSAGE
|
|
10
|
+
};
|
|
11
|
+
function requiredString() {
|
|
12
|
+
return zod.z.string(REQUIRED_STRING_PARAMS);
|
|
13
|
+
}
|
|
7
14
|
function textField(maxLength) {
|
|
8
|
-
const base =
|
|
15
|
+
const base = requiredString().trim().min(1, REQUIRED_MESSAGE);
|
|
9
16
|
return maxLength === void 0 ? base : base.max(maxLength, `M\xE1ximo ${maxLength} caracteres`);
|
|
10
17
|
}
|
|
11
|
-
var numberField = zod.z.number({ invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).nonnegative("Valor n\xE3o pode ser negativo");
|
|
12
|
-
var integerField = zod.z.number({ invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).int("Deve ser um n\xFAmero inteiro").nonnegative("Valor n\xE3o pode ser negativo");
|
|
18
|
+
var numberField = zod.z.number({ required_error: REQUIRED_MESSAGE, invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).nonnegative("Valor n\xE3o pode ser negativo");
|
|
19
|
+
var integerField = zod.z.number({ required_error: REQUIRED_MESSAGE, invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).int("Deve ser um n\xFAmero inteiro").nonnegative("Valor n\xE3o pode ser negativo");
|
|
13
20
|
function enumField(values) {
|
|
14
21
|
return zod.z.enum(values, {
|
|
15
22
|
errorMap: (issue, ctx) => {
|
|
@@ -22,13 +29,16 @@ function enumField(values) {
|
|
|
22
29
|
}
|
|
23
30
|
var MAX_UPLOAD_BYTES = 5 * 1024 * 1024;
|
|
24
31
|
var ACCEPTED_UPLOAD_MIME = ["image/jpeg", "image/png", "application/pdf"];
|
|
25
|
-
var fileUploadField = zod.z.object(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
var fileUploadField = zod.z.object(
|
|
33
|
+
{
|
|
34
|
+
url: zod.z.string().url().optional(),
|
|
35
|
+
mime: zod.z.enum(ACCEPTED_UPLOAD_MIME, {
|
|
36
|
+
errorMap: () => ({ message: "Formato deve ser JPEG, PNG ou PDF" })
|
|
37
|
+
}),
|
|
38
|
+
sizeBytes: zod.z.number().max(MAX_UPLOAD_BYTES, "Arquivo deve ter no m\xE1ximo 5MB")
|
|
39
|
+
},
|
|
40
|
+
REQUIRED_STRING_PARAMS
|
|
41
|
+
);
|
|
32
42
|
|
|
33
43
|
// src/shared/enums/nature-of-occupation-type.ts
|
|
34
44
|
var NatureOfOccupationTypeEnum = enumField(["autonomo", "clt", "aposentado", "empresario"]);
|
|
@@ -69,6 +79,15 @@ var DocumentTypeEnum = enumField([
|
|
|
69
79
|
"carteira_nacional_de_habilita\xE7\xE3o"
|
|
70
80
|
]);
|
|
71
81
|
|
|
82
|
+
// src/shared/enums/proof-kinship-type.ts
|
|
83
|
+
var ProofKinshipTypeEnum = enumField([
|
|
84
|
+
"certidao_casamento",
|
|
85
|
+
"documento_identificacao",
|
|
86
|
+
"contrato_social",
|
|
87
|
+
"declaracao_parentesco",
|
|
88
|
+
"outro_documento"
|
|
89
|
+
]);
|
|
90
|
+
|
|
72
91
|
// src/shared/enums/sex.ts
|
|
73
92
|
var SexEnum = enumField(["masculino", "feminino"]);
|
|
74
93
|
|
|
@@ -199,16 +218,16 @@ function yearsSinceDMY(value, reference = /* @__PURE__ */ new Date()) {
|
|
|
199
218
|
}
|
|
200
219
|
|
|
201
220
|
// src/shared/regex/index.ts
|
|
202
|
-
var cpfSchema =
|
|
203
|
-
var cnpjSchema =
|
|
204
|
-
var cpfCnpjSchema =
|
|
221
|
+
var cpfSchema = requiredString().transform(onlyDigits).refine((v) => PATTERNS.cpf.test(v), "CPF inv\xE1lido").refine(isValidCPF, "CPF inv\xE1lido");
|
|
222
|
+
var cnpjSchema = requiredString().transform(onlyDigits).refine((v) => PATTERNS.cnpj.test(v), "CNPJ inv\xE1lido").refine(isValidCNPJ, "CNPJ inv\xE1lido");
|
|
223
|
+
var cpfCnpjSchema = requiredString().transform(onlyDigits).refine(
|
|
205
224
|
(v) => PATTERNS.cpf.test(v) || PATTERNS.cnpj.test(v),
|
|
206
225
|
"Documento deve ter 11 (CPF) ou 14 (CNPJ) d\xEDgitos"
|
|
207
226
|
).refine((v) => v.length === 11 ? isValidCPF(v) : isValidCNPJ(v), "Documento inv\xE1lido");
|
|
208
|
-
var cepSchema =
|
|
209
|
-
var phoneBRSchema =
|
|
210
|
-
var emailSchema =
|
|
211
|
-
var dateDMYSchema =
|
|
227
|
+
var cepSchema = requiredString().transform(onlyDigits).refine((v) => PATTERNS.cep.test(v), "CEP inv\xE1lido");
|
|
228
|
+
var phoneBRSchema = requiredString().transform(onlyDigits).refine((v) => PATTERNS.phoneBR.test(v), "Telefone inv\xE1lido");
|
|
229
|
+
var emailSchema = requiredString().trim().refine((v) => PATTERNS.email.test(v), "E-mail inv\xE1lido");
|
|
230
|
+
var dateDMYSchema = requiredString().refine((v) => PATTERNS.dateDMY.test(v), "Data inv\xE1lida").refine((v) => parseDMY(v) !== null, "Data inexistente no calend\xE1rio");
|
|
212
231
|
var birthDateSchema = dateDMYSchema.refine(
|
|
213
232
|
(v) => isAdultDMY(v),
|
|
214
233
|
"\xC9 necess\xE1rio ser maior de idade (18+)"
|
|
@@ -217,10 +236,11 @@ var issueDateSchema = dateDMYSchema.refine(
|
|
|
217
236
|
(v) => isNotFutureDMY(v),
|
|
218
237
|
"Data de emiss\xE3o n\xE3o pode ser futura"
|
|
219
238
|
);
|
|
220
|
-
var currencySchema = zod.z.number({ invalid_type_error: "Valor monet\xE1rio inv\xE1lido" }).positive("Valor deve ser positivo");
|
|
221
|
-
zod.z.number().int("Deve ser um n\xFAmero inteiro").min(1, "M\xEDnimo 1").max(28, "M\xE1ximo 28");
|
|
239
|
+
var currencySchema = zod.z.number({ required_error: REQUIRED_MESSAGE, invalid_type_error: "Valor monet\xE1rio inv\xE1lido" }).positive("Valor deve ser positivo");
|
|
240
|
+
zod.z.number({ required_error: REQUIRED_MESSAGE, invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).int("Deve ser um n\xFAmero inteiro").min(1, "M\xEDnimo 1").max(28, "M\xE1ximo 28");
|
|
222
241
|
var formalizationExtras = {
|
|
223
242
|
voucher_local_installation_address: fileUploadField,
|
|
243
|
+
proof_kinship_type: ProofKinshipTypeEnum.optional(),
|
|
224
244
|
proof_kinship: fileUploadField.optional(),
|
|
225
245
|
document_front_upload: fileUploadField,
|
|
226
246
|
document_back_upload: fileUploadField,
|
|
@@ -263,7 +283,18 @@ function applyPartnerRefinement(data, ctx) {
|
|
|
263
283
|
}
|
|
264
284
|
}
|
|
265
285
|
function applyCommonRefinements(data, ctx) {
|
|
266
|
-
|
|
286
|
+
const accountInThirdPartyName = data.energy_account_in_requester_name === "sim";
|
|
287
|
+
if (!accountInThirdPartyName) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (!data.proof_kinship_type) {
|
|
291
|
+
ctx.addIssue({
|
|
292
|
+
code: zod.z.ZodIssueCode.custom,
|
|
293
|
+
path: ["proof_kinship_type"],
|
|
294
|
+
message: "Tipo de comprovante \xE9 obrigat\xF3rio quando a conta est\xE1 em nome de terceiro"
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
if (!data.proof_kinship) {
|
|
267
298
|
ctx.addIssue({
|
|
268
299
|
code: zod.z.ZodIssueCode.custom,
|
|
269
300
|
path: ["proof_kinship"],
|
|
@@ -305,7 +336,7 @@ var unifiedPfObject = zod.z.object({
|
|
|
305
336
|
complement: textField(15).optional(),
|
|
306
337
|
mother_name: textField(),
|
|
307
338
|
district: textField(),
|
|
308
|
-
energy_account_in_requester_name:
|
|
339
|
+
energy_account_in_requester_name: YesOrNoEnum,
|
|
309
340
|
city: textField(),
|
|
310
341
|
energy_bill_owner_document: cpfCnpjSchema.optional(),
|
|
311
342
|
state: UfEnum,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { unifiedPfObject, unifiedPfSchema } from '../../../chunk-
|
|
2
|
-
import '../../../chunk-
|
|
3
|
-
import '../../../chunk-
|
|
1
|
+
export { unifiedPfObject, unifiedPfSchema } from '../../../chunk-Y7TQ2NQ2.mjs';
|
|
2
|
+
import '../../../chunk-CSGG5DZE.mjs';
|
|
3
|
+
import '../../../chunk-5YFVPFSM.mjs';
|
|
@@ -281,6 +281,7 @@ declare const unifiedPjObject: z.ZodObject<{
|
|
|
281
281
|
sizeBytes: number;
|
|
282
282
|
url?: string | undefined;
|
|
283
283
|
}>;
|
|
284
|
+
proof_kinship_type: z.ZodOptional<z.ZodEnum<[string, string, string, string, string]>>;
|
|
284
285
|
proof_kinship: z.ZodOptional<z.ZodObject<{
|
|
285
286
|
url: z.ZodOptional<z.ZodString>;
|
|
286
287
|
mime: z.ZodEnum<["image/jpeg", "image/png", "application/pdf"]>;
|
|
@@ -359,6 +360,7 @@ declare const unifiedPjObject: z.ZodObject<{
|
|
|
359
360
|
months_in_residence?: number | undefined;
|
|
360
361
|
capital_social?: number | undefined;
|
|
361
362
|
};
|
|
363
|
+
proof_kinship_type?: string | undefined;
|
|
362
364
|
proof_kinship?: {
|
|
363
365
|
mime: "image/jpeg" | "image/png" | "application/pdf";
|
|
364
366
|
sizeBytes: number;
|
|
@@ -471,6 +473,7 @@ declare const unifiedPjObject: z.ZodObject<{
|
|
|
471
473
|
months_in_residence?: number | undefined;
|
|
472
474
|
capital_social?: number | undefined;
|
|
473
475
|
};
|
|
476
|
+
proof_kinship_type?: string | undefined;
|
|
474
477
|
proof_kinship?: {
|
|
475
478
|
mime: "image/jpeg" | "image/png" | "application/pdf";
|
|
476
479
|
sizeBytes: number;
|
|
@@ -829,6 +832,7 @@ declare const unifiedPjSchema: z.ZodEffects<z.ZodObject<{
|
|
|
829
832
|
sizeBytes: number;
|
|
830
833
|
url?: string | undefined;
|
|
831
834
|
}>;
|
|
835
|
+
proof_kinship_type: z.ZodOptional<z.ZodEnum<[string, string, string, string, string]>>;
|
|
832
836
|
proof_kinship: z.ZodOptional<z.ZodObject<{
|
|
833
837
|
url: z.ZodOptional<z.ZodString>;
|
|
834
838
|
mime: z.ZodEnum<["image/jpeg", "image/png", "application/pdf"]>;
|
|
@@ -907,6 +911,7 @@ declare const unifiedPjSchema: z.ZodEffects<z.ZodObject<{
|
|
|
907
911
|
months_in_residence?: number | undefined;
|
|
908
912
|
capital_social?: number | undefined;
|
|
909
913
|
};
|
|
914
|
+
proof_kinship_type?: string | undefined;
|
|
910
915
|
proof_kinship?: {
|
|
911
916
|
mime: "image/jpeg" | "image/png" | "application/pdf";
|
|
912
917
|
sizeBytes: number;
|
|
@@ -1019,6 +1024,7 @@ declare const unifiedPjSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1019
1024
|
months_in_residence?: number | undefined;
|
|
1020
1025
|
capital_social?: number | undefined;
|
|
1021
1026
|
};
|
|
1027
|
+
proof_kinship_type?: string | undefined;
|
|
1022
1028
|
proof_kinship?: {
|
|
1023
1029
|
mime: "image/jpeg" | "image/png" | "application/pdf";
|
|
1024
1030
|
sizeBytes: number;
|
|
@@ -1133,6 +1139,7 @@ declare const unifiedPjSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1133
1139
|
months_in_residence?: number | undefined;
|
|
1134
1140
|
capital_social?: number | undefined;
|
|
1135
1141
|
};
|
|
1142
|
+
proof_kinship_type?: string | undefined;
|
|
1136
1143
|
proof_kinship?: {
|
|
1137
1144
|
mime: "image/jpeg" | "image/png" | "application/pdf";
|
|
1138
1145
|
sizeBytes: number;
|
|
@@ -1245,6 +1252,7 @@ declare const unifiedPjSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1245
1252
|
months_in_residence?: number | undefined;
|
|
1246
1253
|
capital_social?: number | undefined;
|
|
1247
1254
|
};
|
|
1255
|
+
proof_kinship_type?: string | undefined;
|
|
1248
1256
|
proof_kinship?: {
|
|
1249
1257
|
mime: "image/jpeg" | "image/png" | "application/pdf";
|
|
1250
1258
|
sizeBytes: number;
|
|
@@ -281,6 +281,7 @@ declare const unifiedPjObject: z.ZodObject<{
|
|
|
281
281
|
sizeBytes: number;
|
|
282
282
|
url?: string | undefined;
|
|
283
283
|
}>;
|
|
284
|
+
proof_kinship_type: z.ZodOptional<z.ZodEnum<[string, string, string, string, string]>>;
|
|
284
285
|
proof_kinship: z.ZodOptional<z.ZodObject<{
|
|
285
286
|
url: z.ZodOptional<z.ZodString>;
|
|
286
287
|
mime: z.ZodEnum<["image/jpeg", "image/png", "application/pdf"]>;
|
|
@@ -359,6 +360,7 @@ declare const unifiedPjObject: z.ZodObject<{
|
|
|
359
360
|
months_in_residence?: number | undefined;
|
|
360
361
|
capital_social?: number | undefined;
|
|
361
362
|
};
|
|
363
|
+
proof_kinship_type?: string | undefined;
|
|
362
364
|
proof_kinship?: {
|
|
363
365
|
mime: "image/jpeg" | "image/png" | "application/pdf";
|
|
364
366
|
sizeBytes: number;
|
|
@@ -471,6 +473,7 @@ declare const unifiedPjObject: z.ZodObject<{
|
|
|
471
473
|
months_in_residence?: number | undefined;
|
|
472
474
|
capital_social?: number | undefined;
|
|
473
475
|
};
|
|
476
|
+
proof_kinship_type?: string | undefined;
|
|
474
477
|
proof_kinship?: {
|
|
475
478
|
mime: "image/jpeg" | "image/png" | "application/pdf";
|
|
476
479
|
sizeBytes: number;
|
|
@@ -829,6 +832,7 @@ declare const unifiedPjSchema: z.ZodEffects<z.ZodObject<{
|
|
|
829
832
|
sizeBytes: number;
|
|
830
833
|
url?: string | undefined;
|
|
831
834
|
}>;
|
|
835
|
+
proof_kinship_type: z.ZodOptional<z.ZodEnum<[string, string, string, string, string]>>;
|
|
832
836
|
proof_kinship: z.ZodOptional<z.ZodObject<{
|
|
833
837
|
url: z.ZodOptional<z.ZodString>;
|
|
834
838
|
mime: z.ZodEnum<["image/jpeg", "image/png", "application/pdf"]>;
|
|
@@ -907,6 +911,7 @@ declare const unifiedPjSchema: z.ZodEffects<z.ZodObject<{
|
|
|
907
911
|
months_in_residence?: number | undefined;
|
|
908
912
|
capital_social?: number | undefined;
|
|
909
913
|
};
|
|
914
|
+
proof_kinship_type?: string | undefined;
|
|
910
915
|
proof_kinship?: {
|
|
911
916
|
mime: "image/jpeg" | "image/png" | "application/pdf";
|
|
912
917
|
sizeBytes: number;
|
|
@@ -1019,6 +1024,7 @@ declare const unifiedPjSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1019
1024
|
months_in_residence?: number | undefined;
|
|
1020
1025
|
capital_social?: number | undefined;
|
|
1021
1026
|
};
|
|
1027
|
+
proof_kinship_type?: string | undefined;
|
|
1022
1028
|
proof_kinship?: {
|
|
1023
1029
|
mime: "image/jpeg" | "image/png" | "application/pdf";
|
|
1024
1030
|
sizeBytes: number;
|
|
@@ -1133,6 +1139,7 @@ declare const unifiedPjSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1133
1139
|
months_in_residence?: number | undefined;
|
|
1134
1140
|
capital_social?: number | undefined;
|
|
1135
1141
|
};
|
|
1142
|
+
proof_kinship_type?: string | undefined;
|
|
1136
1143
|
proof_kinship?: {
|
|
1137
1144
|
mime: "image/jpeg" | "image/png" | "application/pdf";
|
|
1138
1145
|
sizeBytes: number;
|
|
@@ -1245,6 +1252,7 @@ declare const unifiedPjSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1245
1252
|
months_in_residence?: number | undefined;
|
|
1246
1253
|
capital_social?: number | undefined;
|
|
1247
1254
|
};
|
|
1255
|
+
proof_kinship_type?: string | undefined;
|
|
1248
1256
|
proof_kinship?: {
|
|
1249
1257
|
mime: "image/jpeg" | "image/png" | "application/pdf";
|
|
1250
1258
|
sizeBytes: number;
|
|
@@ -4,12 +4,19 @@ var zod = require('zod');
|
|
|
4
4
|
|
|
5
5
|
// src/domains/financing/formalization/schemas/UnifiedPJSchema.ts
|
|
6
6
|
var REQUIRED_MESSAGE = "Campo obrigat\xF3rio";
|
|
7
|
+
var REQUIRED_STRING_PARAMS = {
|
|
8
|
+
required_error: REQUIRED_MESSAGE,
|
|
9
|
+
invalid_type_error: REQUIRED_MESSAGE
|
|
10
|
+
};
|
|
11
|
+
function requiredString() {
|
|
12
|
+
return zod.z.string(REQUIRED_STRING_PARAMS);
|
|
13
|
+
}
|
|
7
14
|
function textField(maxLength) {
|
|
8
|
-
const base =
|
|
15
|
+
const base = requiredString().trim().min(1, REQUIRED_MESSAGE);
|
|
9
16
|
return maxLength === void 0 ? base : base.max(maxLength, `M\xE1ximo ${maxLength} caracteres`);
|
|
10
17
|
}
|
|
11
|
-
zod.z.number({ invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).nonnegative("Valor n\xE3o pode ser negativo");
|
|
12
|
-
var integerField = zod.z.number({ invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).int("Deve ser um n\xFAmero inteiro").nonnegative("Valor n\xE3o pode ser negativo");
|
|
18
|
+
zod.z.number({ required_error: REQUIRED_MESSAGE, invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).nonnegative("Valor n\xE3o pode ser negativo");
|
|
19
|
+
var integerField = zod.z.number({ required_error: REQUIRED_MESSAGE, invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).int("Deve ser um n\xFAmero inteiro").nonnegative("Valor n\xE3o pode ser negativo");
|
|
13
20
|
function enumField(values) {
|
|
14
21
|
return zod.z.enum(values, {
|
|
15
22
|
errorMap: (issue, ctx) => {
|
|
@@ -22,13 +29,16 @@ function enumField(values) {
|
|
|
22
29
|
}
|
|
23
30
|
var MAX_UPLOAD_BYTES = 5 * 1024 * 1024;
|
|
24
31
|
var ACCEPTED_UPLOAD_MIME = ["image/jpeg", "image/png", "application/pdf"];
|
|
25
|
-
var fileUploadField = zod.z.object(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
var fileUploadField = zod.z.object(
|
|
33
|
+
{
|
|
34
|
+
url: zod.z.string().url().optional(),
|
|
35
|
+
mime: zod.z.enum(ACCEPTED_UPLOAD_MIME, {
|
|
36
|
+
errorMap: () => ({ message: "Formato deve ser JPEG, PNG ou PDF" })
|
|
37
|
+
}),
|
|
38
|
+
sizeBytes: zod.z.number().max(MAX_UPLOAD_BYTES, "Arquivo deve ter no m\xE1ximo 5MB")
|
|
39
|
+
},
|
|
40
|
+
REQUIRED_STRING_PARAMS
|
|
41
|
+
);
|
|
32
42
|
|
|
33
43
|
// src/shared/enums/document-type.ts
|
|
34
44
|
var DocumentTypeEnum = enumField([
|
|
@@ -36,6 +46,15 @@ var DocumentTypeEnum = enumField([
|
|
|
36
46
|
"carteira_nacional_de_habilita\xE7\xE3o"
|
|
37
47
|
]);
|
|
38
48
|
|
|
49
|
+
// src/shared/enums/proof-kinship-type.ts
|
|
50
|
+
var ProofKinshipTypeEnum = enumField([
|
|
51
|
+
"certidao_casamento",
|
|
52
|
+
"documento_identificacao",
|
|
53
|
+
"contrato_social",
|
|
54
|
+
"declaracao_parentesco",
|
|
55
|
+
"outro_documento"
|
|
56
|
+
]);
|
|
57
|
+
|
|
39
58
|
// src/shared/enums/sex.ts
|
|
40
59
|
var SexEnum = enumField(["masculino", "feminino"]);
|
|
41
60
|
|
|
@@ -159,16 +178,16 @@ function isNotFutureDMY(value, reference = /* @__PURE__ */ new Date()) {
|
|
|
159
178
|
}
|
|
160
179
|
|
|
161
180
|
// src/shared/regex/index.ts
|
|
162
|
-
var cpfSchema =
|
|
163
|
-
var cnpjSchema =
|
|
164
|
-
|
|
181
|
+
var cpfSchema = requiredString().transform(onlyDigits).refine((v) => PATTERNS.cpf.test(v), "CPF inv\xE1lido").refine(isValidCPF, "CPF inv\xE1lido");
|
|
182
|
+
var cnpjSchema = requiredString().transform(onlyDigits).refine((v) => PATTERNS.cnpj.test(v), "CNPJ inv\xE1lido").refine(isValidCNPJ, "CNPJ inv\xE1lido");
|
|
183
|
+
requiredString().transform(onlyDigits).refine(
|
|
165
184
|
(v) => PATTERNS.cpf.test(v) || PATTERNS.cnpj.test(v),
|
|
166
185
|
"Documento deve ter 11 (CPF) ou 14 (CNPJ) d\xEDgitos"
|
|
167
186
|
).refine((v) => v.length === 11 ? isValidCPF(v) : isValidCNPJ(v), "Documento inv\xE1lido");
|
|
168
|
-
var cepSchema =
|
|
169
|
-
var phoneBRSchema =
|
|
170
|
-
var emailSchema =
|
|
171
|
-
var dateDMYSchema =
|
|
187
|
+
var cepSchema = requiredString().transform(onlyDigits).refine((v) => PATTERNS.cep.test(v), "CEP inv\xE1lido");
|
|
188
|
+
var phoneBRSchema = requiredString().transform(onlyDigits).refine((v) => PATTERNS.phoneBR.test(v), "Telefone inv\xE1lido");
|
|
189
|
+
var emailSchema = requiredString().trim().refine((v) => PATTERNS.email.test(v), "E-mail inv\xE1lido");
|
|
190
|
+
var dateDMYSchema = requiredString().refine((v) => PATTERNS.dateDMY.test(v), "Data inv\xE1lida").refine((v) => parseDMY(v) !== null, "Data inexistente no calend\xE1rio");
|
|
172
191
|
var birthDateSchema = dateDMYSchema.refine(
|
|
173
192
|
(v) => isAdultDMY(v),
|
|
174
193
|
"\xC9 necess\xE1rio ser maior de idade (18+)"
|
|
@@ -177,17 +196,29 @@ var issueDateSchema = dateDMYSchema.refine(
|
|
|
177
196
|
(v) => isNotFutureDMY(v),
|
|
178
197
|
"Data de emiss\xE3o n\xE3o pode ser futura"
|
|
179
198
|
);
|
|
180
|
-
var currencySchema = zod.z.number({ invalid_type_error: "Valor monet\xE1rio inv\xE1lido" }).positive("Valor deve ser positivo");
|
|
181
|
-
zod.z.number().int("Deve ser um n\xFAmero inteiro").min(1, "M\xEDnimo 1").max(28, "M\xE1ximo 28");
|
|
199
|
+
var currencySchema = zod.z.number({ required_error: REQUIRED_MESSAGE, invalid_type_error: "Valor monet\xE1rio inv\xE1lido" }).positive("Valor deve ser positivo");
|
|
200
|
+
zod.z.number({ required_error: REQUIRED_MESSAGE, invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).int("Deve ser um n\xFAmero inteiro").min(1, "M\xEDnimo 1").max(28, "M\xE1ximo 28");
|
|
182
201
|
var formalizationExtras = {
|
|
183
202
|
voucher_local_installation_address: fileUploadField,
|
|
203
|
+
proof_kinship_type: ProofKinshipTypeEnum.optional(),
|
|
184
204
|
proof_kinship: fileUploadField.optional(),
|
|
185
205
|
document_front_upload: fileUploadField,
|
|
186
206
|
document_back_upload: fileUploadField,
|
|
187
207
|
rd_re_insurance_toggle: zod.z.boolean().default(true)
|
|
188
208
|
};
|
|
189
209
|
function applyCommonRefinements(data, ctx) {
|
|
190
|
-
|
|
210
|
+
const accountInThirdPartyName = data.energy_account_in_requester_name === "sim";
|
|
211
|
+
if (!accountInThirdPartyName) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (!data.proof_kinship_type) {
|
|
215
|
+
ctx.addIssue({
|
|
216
|
+
code: zod.z.ZodIssueCode.custom,
|
|
217
|
+
path: ["proof_kinship_type"],
|
|
218
|
+
message: "Tipo de comprovante \xE9 obrigat\xF3rio quando a conta est\xE1 em nome de terceiro"
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
if (!data.proof_kinship) {
|
|
191
222
|
ctx.addIssue({
|
|
192
223
|
code: zod.z.ZodIssueCode.custom,
|
|
193
224
|
path: ["proof_kinship"],
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { unifiedPjObject, unifiedPjSchema } from '../../../chunk-
|
|
2
|
-
import '../../../chunk-
|
|
3
|
-
import '../../../chunk-
|
|
1
|
+
export { unifiedPjObject, unifiedPjSchema } from '../../../chunk-E7JXDCBO.mjs';
|
|
2
|
+
import '../../../chunk-CSGG5DZE.mjs';
|
|
3
|
+
import '../../../chunk-5YFVPFSM.mjs';
|
package/index.js
CHANGED
|
@@ -4,12 +4,19 @@ var zod = require('zod');
|
|
|
4
4
|
|
|
5
5
|
// src/shared/fields/primitives.ts
|
|
6
6
|
var REQUIRED_MESSAGE = "Campo obrigat\xF3rio";
|
|
7
|
+
var REQUIRED_STRING_PARAMS = {
|
|
8
|
+
required_error: REQUIRED_MESSAGE,
|
|
9
|
+
invalid_type_error: REQUIRED_MESSAGE
|
|
10
|
+
};
|
|
11
|
+
function requiredString() {
|
|
12
|
+
return zod.z.string(REQUIRED_STRING_PARAMS);
|
|
13
|
+
}
|
|
7
14
|
function textField(maxLength) {
|
|
8
|
-
const base =
|
|
15
|
+
const base = requiredString().trim().min(1, REQUIRED_MESSAGE);
|
|
9
16
|
return maxLength === void 0 ? base : base.max(maxLength, `M\xE1ximo ${maxLength} caracteres`);
|
|
10
17
|
}
|
|
11
|
-
var numberField = zod.z.number({ invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).nonnegative("Valor n\xE3o pode ser negativo");
|
|
12
|
-
var integerField = zod.z.number({ invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).int("Deve ser um n\xFAmero inteiro").nonnegative("Valor n\xE3o pode ser negativo");
|
|
18
|
+
var numberField = zod.z.number({ required_error: REQUIRED_MESSAGE, invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).nonnegative("Valor n\xE3o pode ser negativo");
|
|
19
|
+
var integerField = zod.z.number({ required_error: REQUIRED_MESSAGE, invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).int("Deve ser um n\xFAmero inteiro").nonnegative("Valor n\xE3o pode ser negativo");
|
|
13
20
|
function enumField(values) {
|
|
14
21
|
return zod.z.enum(values, {
|
|
15
22
|
errorMap: (issue, ctx) => {
|
|
@@ -22,13 +29,16 @@ function enumField(values) {
|
|
|
22
29
|
}
|
|
23
30
|
var MAX_UPLOAD_BYTES = 5 * 1024 * 1024;
|
|
24
31
|
var ACCEPTED_UPLOAD_MIME = ["image/jpeg", "image/png", "application/pdf"];
|
|
25
|
-
var fileUploadField = zod.z.object(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
var fileUploadField = zod.z.object(
|
|
33
|
+
{
|
|
34
|
+
url: zod.z.string().url().optional(),
|
|
35
|
+
mime: zod.z.enum(ACCEPTED_UPLOAD_MIME, {
|
|
36
|
+
errorMap: () => ({ message: "Formato deve ser JPEG, PNG ou PDF" })
|
|
37
|
+
}),
|
|
38
|
+
sizeBytes: zod.z.number().max(MAX_UPLOAD_BYTES, "Arquivo deve ter no m\xE1ximo 5MB")
|
|
39
|
+
},
|
|
40
|
+
REQUIRED_STRING_PARAMS
|
|
41
|
+
);
|
|
32
42
|
|
|
33
43
|
// src/shared/enums/civil-status.ts
|
|
34
44
|
var CivilStatusEnum = enumField([
|
|
@@ -84,6 +94,22 @@ var NatureOfOccupationTypeLabels = {
|
|
|
84
94
|
empresario: "Empres\xE1rio"
|
|
85
95
|
};
|
|
86
96
|
|
|
97
|
+
// src/shared/enums/proof-kinship-type.ts
|
|
98
|
+
var ProofKinshipTypeEnum = enumField([
|
|
99
|
+
"certidao_casamento",
|
|
100
|
+
"documento_identificacao",
|
|
101
|
+
"contrato_social",
|
|
102
|
+
"declaracao_parentesco",
|
|
103
|
+
"outro_documento"
|
|
104
|
+
]);
|
|
105
|
+
var ProofKinshipTypeLabels = {
|
|
106
|
+
certidao_casamento: "Certid\xE3o de casamento",
|
|
107
|
+
documento_identificacao: "Documento de identifica\xE7\xE3o",
|
|
108
|
+
contrato_social: "Contrato social",
|
|
109
|
+
declaracao_parentesco: "Declara\xE7\xE3o de parentesco",
|
|
110
|
+
outro_documento: "Outro documento"
|
|
111
|
+
};
|
|
112
|
+
|
|
87
113
|
// src/shared/enums/residence-type.ts
|
|
88
114
|
var ResidenceTypeEnum = enumField([
|
|
89
115
|
"proprio",
|
|
@@ -222,7 +248,9 @@ var FORMALIZATION_OPTION_LABELS = {
|
|
|
222
248
|
uf_naturalness: UfLabels,
|
|
223
249
|
emitting_state: UfLabels,
|
|
224
250
|
uf_issuing_body: UfLabels,
|
|
225
|
-
doc_issuance_uf: UfLabels
|
|
251
|
+
doc_issuance_uf: UfLabels,
|
|
252
|
+
energy_account_in_requester_name: YesOrNoLabels,
|
|
253
|
+
proof_kinship_type: ProofKinshipTypeLabels
|
|
226
254
|
};
|
|
227
255
|
function getFieldOptions(field) {
|
|
228
256
|
const labels = FORMALIZATION_OPTION_LABELS[field];
|
|
@@ -328,16 +356,16 @@ function yearsSinceDMY(value, reference = /* @__PURE__ */ new Date()) {
|
|
|
328
356
|
}
|
|
329
357
|
|
|
330
358
|
// src/shared/regex/index.ts
|
|
331
|
-
var cpfSchema =
|
|
332
|
-
var cnpjSchema =
|
|
333
|
-
var cpfCnpjSchema =
|
|
359
|
+
var cpfSchema = requiredString().transform(onlyDigits).refine((v) => PATTERNS.cpf.test(v), "CPF inv\xE1lido").refine(isValidCPF, "CPF inv\xE1lido");
|
|
360
|
+
var cnpjSchema = requiredString().transform(onlyDigits).refine((v) => PATTERNS.cnpj.test(v), "CNPJ inv\xE1lido").refine(isValidCNPJ, "CNPJ inv\xE1lido");
|
|
361
|
+
var cpfCnpjSchema = requiredString().transform(onlyDigits).refine(
|
|
334
362
|
(v) => PATTERNS.cpf.test(v) || PATTERNS.cnpj.test(v),
|
|
335
363
|
"Documento deve ter 11 (CPF) ou 14 (CNPJ) d\xEDgitos"
|
|
336
364
|
).refine((v) => v.length === 11 ? isValidCPF(v) : isValidCNPJ(v), "Documento inv\xE1lido");
|
|
337
|
-
var cepSchema =
|
|
338
|
-
var phoneBRSchema =
|
|
339
|
-
var emailSchema =
|
|
340
|
-
var dateDMYSchema =
|
|
365
|
+
var cepSchema = requiredString().transform(onlyDigits).refine((v) => PATTERNS.cep.test(v), "CEP inv\xE1lido");
|
|
366
|
+
var phoneBRSchema = requiredString().transform(onlyDigits).refine((v) => PATTERNS.phoneBR.test(v), "Telefone inv\xE1lido");
|
|
367
|
+
var emailSchema = requiredString().trim().refine((v) => PATTERNS.email.test(v), "E-mail inv\xE1lido");
|
|
368
|
+
var dateDMYSchema = requiredString().refine((v) => PATTERNS.dateDMY.test(v), "Data inv\xE1lida").refine((v) => parseDMY(v) !== null, "Data inexistente no calend\xE1rio");
|
|
341
369
|
var birthDateSchema = dateDMYSchema.refine(
|
|
342
370
|
(v) => isAdultDMY(v),
|
|
343
371
|
"\xC9 necess\xE1rio ser maior de idade (18+)"
|
|
@@ -346,8 +374,8 @@ var issueDateSchema = dateDMYSchema.refine(
|
|
|
346
374
|
(v) => isNotFutureDMY(v),
|
|
347
375
|
"Data de emiss\xE3o n\xE3o pode ser futura"
|
|
348
376
|
);
|
|
349
|
-
var currencySchema = zod.z.number({ invalid_type_error: "Valor monet\xE1rio inv\xE1lido" }).positive("Valor deve ser positivo");
|
|
350
|
-
zod.z.number().int("Deve ser um n\xFAmero inteiro").min(1, "M\xEDnimo 1").max(28, "M\xE1ximo 28");
|
|
377
|
+
var currencySchema = zod.z.number({ required_error: REQUIRED_MESSAGE, invalid_type_error: "Valor monet\xE1rio inv\xE1lido" }).positive("Valor deve ser positivo");
|
|
378
|
+
zod.z.number({ required_error: REQUIRED_MESSAGE, invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).int("Deve ser um n\xFAmero inteiro").min(1, "M\xEDnimo 1").max(28, "M\xE1ximo 28");
|
|
351
379
|
|
|
352
380
|
// src/domains/financing/formalization/refinements.ts
|
|
353
381
|
var RG_MAX_EMISSION_YEARS = 10;
|
|
@@ -370,7 +398,18 @@ function applyPartnerRefinement(data, ctx) {
|
|
|
370
398
|
}
|
|
371
399
|
}
|
|
372
400
|
function applyCommonRefinements(data, ctx) {
|
|
373
|
-
|
|
401
|
+
const accountInThirdPartyName = data.energy_account_in_requester_name === "sim";
|
|
402
|
+
if (!accountInThirdPartyName) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (!data.proof_kinship_type) {
|
|
406
|
+
ctx.addIssue({
|
|
407
|
+
code: zod.z.ZodIssueCode.custom,
|
|
408
|
+
path: ["proof_kinship_type"],
|
|
409
|
+
message: "Tipo de comprovante \xE9 obrigat\xF3rio quando a conta est\xE1 em nome de terceiro"
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
if (!data.proof_kinship) {
|
|
374
413
|
ctx.addIssue({
|
|
375
414
|
code: zod.z.ZodIssueCode.custom,
|
|
376
415
|
path: ["proof_kinship"],
|
|
@@ -404,6 +443,7 @@ function applyPjRefinements(data, ctx) {
|
|
|
404
443
|
}
|
|
405
444
|
var formalizationExtras = {
|
|
406
445
|
voucher_local_installation_address: fileUploadField,
|
|
446
|
+
proof_kinship_type: ProofKinshipTypeEnum.optional(),
|
|
407
447
|
proof_kinship: fileUploadField.optional(),
|
|
408
448
|
document_front_upload: fileUploadField,
|
|
409
449
|
document_back_upload: fileUploadField,
|
|
@@ -1443,7 +1483,7 @@ var unifiedPfObject = zod.z.object({
|
|
|
1443
1483
|
complement: textField(15).optional(),
|
|
1444
1484
|
mother_name: textField(),
|
|
1445
1485
|
district: textField(),
|
|
1446
|
-
energy_account_in_requester_name:
|
|
1486
|
+
energy_account_in_requester_name: YesOrNoEnum,
|
|
1447
1487
|
city: textField(),
|
|
1448
1488
|
energy_bill_owner_document: cpfCnpjSchema.optional(),
|
|
1449
1489
|
state: UfEnum,
|
|
@@ -1694,6 +1734,12 @@ var FORMALIZATION_FIELD_META = {
|
|
|
1694
1734
|
step: 1,
|
|
1695
1735
|
placeholder: "Selecione uma op\xE7\xE3o"
|
|
1696
1736
|
},
|
|
1737
|
+
proof_kinship_type: {
|
|
1738
|
+
kind: "select",
|
|
1739
|
+
label: "Tipo de comprovante",
|
|
1740
|
+
step: 1,
|
|
1741
|
+
placeholder: "Selecione uma op\xE7\xE3o"
|
|
1742
|
+
},
|
|
1697
1743
|
proof_kinship: {
|
|
1698
1744
|
kind: "file",
|
|
1699
1745
|
label: "Documento de v\xEDnculo com o titular",
|
package/index.mjs
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
export { BANK_SLUGS, BankEnum, FORMALIZATION_FIELD_META, FORMALIZATION_OPTION_LABELS, NATIONALITY_BRAZIL, UNIFIED_SLUG, getFieldOptions, getFormalizationBaseSchema, getFormalizationSchema, pfBaseSchemaRegistry, pfSchemaRegistry, pjBaseSchemaRegistry, pjSchemaRegistry } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-
|
|
5
|
-
import './chunk-
|
|
6
|
-
import './chunk-
|
|
7
|
-
import './chunk-
|
|
8
|
-
export { unifiedPfObject, unifiedPfSchema } from './chunk-
|
|
9
|
-
export { unifiedPjObject, unifiedPjSchema } from './chunk-
|
|
10
|
-
import './chunk-
|
|
11
|
-
import './chunk-
|
|
12
|
-
import './chunk-
|
|
13
|
-
import './chunk-
|
|
14
|
-
import './chunk-
|
|
15
|
-
import './chunk-
|
|
16
|
-
import './chunk-
|
|
17
|
-
import './chunk-
|
|
18
|
-
import './chunk-
|
|
19
|
-
import './chunk-
|
|
20
|
-
import './chunk-
|
|
21
|
-
import './chunk-
|
|
22
|
-
import './chunk-
|
|
23
|
-
import './chunk-
|
|
24
|
-
import './chunk-
|
|
25
|
-
import './chunk-
|
|
26
|
-
import './chunk-
|
|
27
|
-
import './chunk-
|
|
28
|
-
import './chunk-
|
|
29
|
-
import './chunk-
|
|
30
|
-
import './chunk-
|
|
31
|
-
import './chunk-
|
|
32
|
-
import './chunk-
|
|
33
|
-
export { CIVIL_STATUS_REQUIRING_PARTNER, OCCUPATIONS_REQUIRING_CNPJ, PARTNER_FIELDS, applyPfRefinements, applyPjRefinements } from './chunk-
|
|
1
|
+
export { BANK_SLUGS, BankEnum, FORMALIZATION_FIELD_META, FORMALIZATION_OPTION_LABELS, NATIONALITY_BRAZIL, UNIFIED_SLUG, getFieldOptions, getFormalizationBaseSchema, getFormalizationSchema, pfBaseSchemaRegistry, pfSchemaRegistry, pjBaseSchemaRegistry, pjSchemaRegistry } from './chunk-AQ43O5UO.mjs';
|
|
2
|
+
import './chunk-T2MFLA6J.mjs';
|
|
3
|
+
import './chunk-GVOOT43S.mjs';
|
|
4
|
+
import './chunk-UYCCHEM5.mjs';
|
|
5
|
+
import './chunk-LOEAPRSO.mjs';
|
|
6
|
+
import './chunk-ZQ2PKLTM.mjs';
|
|
7
|
+
import './chunk-O5XQR5HN.mjs';
|
|
8
|
+
export { unifiedPfObject, unifiedPfSchema } from './chunk-Y7TQ2NQ2.mjs';
|
|
9
|
+
export { unifiedPjObject, unifiedPjSchema } from './chunk-E7JXDCBO.mjs';
|
|
10
|
+
import './chunk-LEUH6IFB.mjs';
|
|
11
|
+
import './chunk-K23FTEKB.mjs';
|
|
12
|
+
import './chunk-WPJOW7IE.mjs';
|
|
13
|
+
import './chunk-X4LHQVVJ.mjs';
|
|
14
|
+
import './chunk-66Y3FO5R.mjs';
|
|
15
|
+
import './chunk-PY7IUNIU.mjs';
|
|
16
|
+
import './chunk-BRBOOPFN.mjs';
|
|
17
|
+
import './chunk-XVITSWCY.mjs';
|
|
18
|
+
import './chunk-35IKZUF4.mjs';
|
|
19
|
+
import './chunk-OFCVHF6Z.mjs';
|
|
20
|
+
import './chunk-BITN6YDR.mjs';
|
|
21
|
+
import './chunk-BSG5DCL7.mjs';
|
|
22
|
+
import './chunk-ISJKYUMR.mjs';
|
|
23
|
+
import './chunk-ACJUTGEC.mjs';
|
|
24
|
+
import './chunk-W6J3SW2H.mjs';
|
|
25
|
+
import './chunk-57DSP6GG.mjs';
|
|
26
|
+
import './chunk-LVFKP46R.mjs';
|
|
27
|
+
import './chunk-RDLOQ6HV.mjs';
|
|
28
|
+
import './chunk-2ZKUSLGU.mjs';
|
|
29
|
+
import './chunk-QUBWDT4D.mjs';
|
|
30
|
+
import './chunk-SKSUT6CG.mjs';
|
|
31
|
+
import './chunk-JBTU6WKN.mjs';
|
|
32
|
+
import './chunk-CSGG5DZE.mjs';
|
|
33
|
+
export { CIVIL_STATUS_REQUIRING_PARTNER, OCCUPATIONS_REQUIRING_CNPJ, PARTNER_FIELDS, applyPfRefinements, applyPjRefinements } from './chunk-5YFVPFSM.mjs';
|
package/package.json
CHANGED