@77sol-lab/form-schemas 1.7.0 → 3.0.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-HMC73HBG.mjs → chunk-4T4DDJJZ.mjs} +7 -7
- package/{chunk-DIYEI2PA.mjs → chunk-65WB3CQB.mjs} +9 -9
- package/{chunk-VP4HT24O.mjs → chunk-6AISIJ3O.mjs} +7 -7
- package/{chunk-LU5ODSGQ.mjs → chunk-7ULQG7YJ.mjs} +9 -9
- package/{chunk-QMODZE4A.mjs → chunk-7VU2KIBV.mjs} +7 -7
- package/chunk-BXLQYGEB.mjs +105 -0
- package/{chunk-VDFDTLU5.mjs → chunk-CGBX6OCD.mjs} +7 -7
- package/{chunk-ENDOIQ32.mjs → chunk-CJSJ3VDW.mjs} +138 -60
- package/{chunk-6ZUOXZY3.mjs → chunk-EG5RVHCZ.mjs} +9 -9
- package/{chunk-5EHEC3RT.mjs → chunk-F4RMWUXJ.mjs} +10 -10
- package/{chunk-KJTTMDZP.mjs → chunk-GBKY6QE3.mjs} +7 -7
- package/{chunk-AM7HTUI3.mjs → chunk-HF7G6PTH.mjs} +9 -9
- package/{chunk-65EE5FW3.mjs → chunk-HX5UJCA2.mjs} +7 -7
- package/{chunk-L3OISOZA.mjs → chunk-HXHJSQ2X.mjs} +9 -9
- package/{chunk-UF45URAJ.mjs → chunk-IVY6IQXZ.mjs} +9 -9
- package/{chunk-FBDTG3WD.mjs → chunk-K3QXEL6M.mjs} +20 -21
- package/{chunk-CPDLICOP.mjs → chunk-LDL7QLPB.mjs} +7 -7
- package/{chunk-ORQ52KPA.mjs → chunk-LRIO6V7H.mjs} +7 -7
- package/{chunk-MM6LQXI6.mjs → chunk-OIGZEDM3.mjs} +7 -7
- package/{chunk-PDBPFNAN.mjs → chunk-OJUTNXHL.mjs} +136 -39
- package/{chunk-KBILM3GO.mjs → chunk-OKAMQBUN.mjs} +7 -7
- package/{chunk-TDL42FZZ.mjs → chunk-PCTF5JYB.mjs} +9 -9
- package/{chunk-2BHUMNK5.mjs → chunk-PCXYLWDD.mjs} +9 -9
- package/chunk-QEPJ2RLU.mjs +18 -0
- package/{chunk-5P6NWFTX.mjs → chunk-QQCSQ3L4.mjs} +10 -10
- package/{chunk-TKHIBI4R.mjs → chunk-R5TJYTTO.mjs} +9 -9
- package/{chunk-U4ZDMJX2.mjs → chunk-T2FBV7WO.mjs} +10 -10
- package/{chunk-RWOX5QO3.mjs → chunk-TNZ33455.mjs} +7 -7
- package/{chunk-Y67MNG2X.mjs → chunk-TWOBBIQC.mjs} +9 -9
- package/{chunk-22SYVROO.mjs → chunk-TZEPVIC4.mjs} +9 -9
- package/{chunk-FIPFWGBQ.mjs → chunk-UK62IINL.mjs} +7 -7
- package/{chunk-BYAXV4TG.mjs → chunk-VTTNXB64.mjs} +7 -7
- package/{chunk-DJDG3UYR.mjs → chunk-VWKF4I2L.mjs} +9 -9
- package/financing/formalization/index.d.cts +4848 -19624
- package/financing/formalization/index.d.ts +4848 -19624
- package/financing/formalization/index.js +516 -278
- package/financing/formalization/index.mjs +33 -33
- package/financing/formalization/schemas/AlfaPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/AlfaPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/AlfaPFSchema.js +127 -47
- package/financing/formalization/schemas/AlfaPFSchema.mjs +3 -3
- package/financing/formalization/schemas/AlfaPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/AlfaPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/AlfaPJSchema.js +188 -46
- package/financing/formalization/schemas/AlfaPJSchema.mjs +2 -2
- package/financing/formalization/schemas/BancoDoBrasilPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/BancoDoBrasilPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/BancoDoBrasilPFSchema.js +127 -47
- package/financing/formalization/schemas/BancoDoBrasilPFSchema.mjs +3 -3
- package/financing/formalization/schemas/BancoDoBrasilPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/BancoDoBrasilPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/BancoDoBrasilPJSchema.js +188 -46
- package/financing/formalization/schemas/BancoDoBrasilPJSchema.mjs +2 -2
- package/financing/formalization/schemas/BtgPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/BtgPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/BtgPFSchema.js +127 -47
- package/financing/formalization/schemas/BtgPFSchema.mjs +3 -3
- package/financing/formalization/schemas/BtgPJSchema.d.cts +147 -747
- package/financing/formalization/schemas/BtgPJSchema.d.ts +147 -747
- package/financing/formalization/schemas/BtgPJSchema.js +193 -47
- package/financing/formalization/schemas/BtgPJSchema.mjs +3 -3
- package/financing/formalization/schemas/BvPFSchema.d.cts +125 -477
- package/financing/formalization/schemas/BvPFSchema.d.ts +125 -477
- package/financing/formalization/schemas/BvPFSchema.js +129 -49
- package/financing/formalization/schemas/BvPFSchema.mjs +3 -3
- package/financing/formalization/schemas/BvPJSchema.d.cts +149 -819
- package/financing/formalization/schemas/BvPJSchema.d.ts +149 -819
- package/financing/formalization/schemas/BvPJSchema.js +193 -47
- package/financing/formalization/schemas/BvPJSchema.mjs +3 -3
- package/financing/formalization/schemas/CaixaEconomicaFederalPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/CaixaEconomicaFederalPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/CaixaEconomicaFederalPFSchema.js +127 -47
- package/financing/formalization/schemas/CaixaEconomicaFederalPFSchema.mjs +3 -3
- package/financing/formalization/schemas/CaixaEconomicaFederalPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/CaixaEconomicaFederalPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/CaixaEconomicaFederalPJSchema.js +188 -46
- package/financing/formalization/schemas/CaixaEconomicaFederalPJSchema.mjs +2 -2
- package/financing/formalization/schemas/CashMePFSchema.d.cts +107 -395
- package/financing/formalization/schemas/CashMePFSchema.d.ts +107 -395
- package/financing/formalization/schemas/CashMePFSchema.js +127 -47
- package/financing/formalization/schemas/CashMePFSchema.mjs +3 -3
- package/financing/formalization/schemas/CashMePJSchema.d.cts +119 -621
- package/financing/formalization/schemas/CashMePJSchema.d.ts +119 -621
- package/financing/formalization/schemas/CashMePJSchema.js +188 -46
- package/financing/formalization/schemas/CashMePJSchema.mjs +2 -2
- package/financing/formalization/schemas/Credito77PFSchema.d.cts +107 -395
- package/financing/formalization/schemas/Credito77PFSchema.d.ts +107 -395
- package/financing/formalization/schemas/Credito77PFSchema.js +127 -47
- package/financing/formalization/schemas/Credito77PFSchema.mjs +3 -3
- package/financing/formalization/schemas/Credito77PJSchema.d.cts +119 -621
- package/financing/formalization/schemas/Credito77PJSchema.d.ts +119 -621
- package/financing/formalization/schemas/Credito77PJSchema.js +188 -46
- package/financing/formalization/schemas/Credito77PJSchema.mjs +2 -2
- package/financing/formalization/schemas/EosPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/EosPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/EosPFSchema.js +127 -47
- package/financing/formalization/schemas/EosPFSchema.mjs +3 -3
- package/financing/formalization/schemas/EosPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/EosPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/EosPJSchema.js +188 -46
- package/financing/formalization/schemas/EosPJSchema.mjs +2 -2
- package/financing/formalization/schemas/HdtEnergyPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/HdtEnergyPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/HdtEnergyPFSchema.js +127 -47
- package/financing/formalization/schemas/HdtEnergyPFSchema.mjs +3 -3
- package/financing/formalization/schemas/HdtEnergyPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/HdtEnergyPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/HdtEnergyPJSchema.js +188 -46
- package/financing/formalization/schemas/HdtEnergyPJSchema.mjs +2 -2
- package/financing/formalization/schemas/LosangoPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/LosangoPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/LosangoPFSchema.js +127 -47
- package/financing/formalization/schemas/LosangoPFSchema.mjs +3 -3
- package/financing/formalization/schemas/LosangoPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/LosangoPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/LosangoPJSchema.js +188 -46
- package/financing/formalization/schemas/LosangoPJSchema.mjs +2 -2
- package/financing/formalization/schemas/SafraPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/SafraPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/SafraPFSchema.js +127 -47
- package/financing/formalization/schemas/SafraPFSchema.mjs +3 -3
- package/financing/formalization/schemas/SafraPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/SafraPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/SafraPJSchema.js +188 -46
- package/financing/formalization/schemas/SafraPJSchema.mjs +2 -2
- package/financing/formalization/schemas/SantanderPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/SantanderPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/SantanderPFSchema.js +127 -47
- package/financing/formalization/schemas/SantanderPFSchema.mjs +3 -3
- package/financing/formalization/schemas/SantanderPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/SantanderPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/SantanderPJSchema.js +188 -46
- package/financing/formalization/schemas/SantanderPJSchema.mjs +2 -2
- package/financing/formalization/schemas/SolAgoraPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/SolAgoraPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/SolAgoraPFSchema.js +127 -47
- package/financing/formalization/schemas/SolAgoraPFSchema.mjs +3 -3
- package/financing/formalization/schemas/SolAgoraPJSchema.d.cts +145 -725
- package/financing/formalization/schemas/SolAgoraPJSchema.d.ts +145 -725
- package/financing/formalization/schemas/SolAgoraPJSchema.js +193 -47
- package/financing/formalization/schemas/SolAgoraPJSchema.mjs +3 -3
- package/financing/formalization/schemas/SolfacilPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/SolfacilPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/SolfacilPFSchema.js +127 -47
- package/financing/formalization/schemas/SolfacilPFSchema.mjs +3 -3
- package/financing/formalization/schemas/SolfacilPJSchema.d.cts +131 -679
- package/financing/formalization/schemas/SolfacilPJSchema.d.ts +131 -679
- package/financing/formalization/schemas/SolfacilPJSchema.js +188 -46
- package/financing/formalization/schemas/SolfacilPJSchema.mjs +2 -2
- package/financing/formalization/schemas/UnifiedPFSchema.d.cts +185 -557
- package/financing/formalization/schemas/UnifiedPFSchema.d.ts +185 -557
- package/financing/formalization/schemas/UnifiedPFSchema.js +141 -61
- package/financing/formalization/schemas/UnifiedPFSchema.mjs +3 -3
- package/financing/formalization/schemas/UnifiedPJSchema.d.cts +265 -1269
- package/financing/formalization/schemas/UnifiedPJSchema.d.ts +265 -1269
- package/financing/formalization/schemas/UnifiedPJSchema.js +238 -92
- package/financing/formalization/schemas/UnifiedPJSchema.mjs +3 -3
- package/index.d.cts +2 -1
- package/index.d.ts +2 -1
- package/index.js +516 -278
- package/index.mjs +33 -33
- package/package.json +2 -2
- package/chunk-4PZYGTUU.mjs +0 -105
- package/chunk-JZ7DY7SU.mjs +0 -13
|
@@ -2,43 +2,71 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
|
|
5
|
-
// src/
|
|
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
7
|
function requiredString() {
|
|
12
|
-
return zod.z.string(
|
|
8
|
+
return zod.z.string({ error: REQUIRED_MESSAGE });
|
|
13
9
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
10
|
+
var DEFAULT_TEXT_MAX_LENGTH = 255;
|
|
11
|
+
function textField(maxLength = DEFAULT_TEXT_MAX_LENGTH) {
|
|
12
|
+
return requiredString().trim().min(1, REQUIRED_MESSAGE).max(maxLength, `M\xE1ximo ${maxLength} caracteres`);
|
|
17
13
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
function requiredNumber(invalidTypeMessage) {
|
|
15
|
+
return zod.z.number({
|
|
16
|
+
error: (issue) => issue.input === void 0 ? REQUIRED_MESSAGE : invalidTypeMessage
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
var numberField = requiredNumber("Valor num\xE9rico inv\xE1lido").nonnegative(
|
|
20
|
+
"Valor n\xE3o pode ser negativo"
|
|
21
|
+
);
|
|
22
|
+
var integerField = requiredNumber("Valor num\xE9rico inv\xE1lido").int("Deve ser um n\xFAmero inteiro").nonnegative("Valor n\xE3o pode ser negativo");
|
|
23
|
+
function optionalField(schema) {
|
|
24
|
+
return zod.z.preprocess(
|
|
25
|
+
(value) => typeof value === "string" && value.trim() === "" ? void 0 : value,
|
|
26
|
+
schema.optional()
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
function unrecognizedKeysMessage(keys) {
|
|
30
|
+
const list = keys.map((key) => `"${key}"`).join(", ");
|
|
31
|
+
return keys.length === 1 ? `Campo n\xE3o reconhecido: ${list}` : `Campos n\xE3o reconhecidos: ${list}`;
|
|
32
|
+
}
|
|
33
|
+
function requiredObject(shape) {
|
|
34
|
+
return zod.z.object(shape, {
|
|
35
|
+
error: (issue) => {
|
|
36
|
+
if (issue.code === "invalid_type") {
|
|
37
|
+
return REQUIRED_MESSAGE;
|
|
38
|
+
}
|
|
39
|
+
if (issue.code === "unrecognized_keys") {
|
|
40
|
+
return unrecognizedKeysMessage(issue.keys);
|
|
25
41
|
}
|
|
26
|
-
return
|
|
42
|
+
return void 0;
|
|
27
43
|
}
|
|
28
44
|
});
|
|
29
45
|
}
|
|
46
|
+
function enumField(values) {
|
|
47
|
+
return zod.z.enum(values, {
|
|
48
|
+
// No zod 4 todo input fora da lista (inclusive undefined/null) gera um único
|
|
49
|
+
// issue `invalid_value`. Tratamos ausência, tipo inválido e string vazia
|
|
50
|
+
// (select não preenchido) como "obrigatório"; um valor de fato inválido cai
|
|
51
|
+
// na mensagem padrão do zod (retornar undefined delega ao error map default).
|
|
52
|
+
error: (issue) => typeof issue.input !== "string" || issue.input === "" ? REQUIRED_MESSAGE : void 0
|
|
53
|
+
});
|
|
54
|
+
}
|
|
30
55
|
var MAX_UPLOAD_BYTES = 5 * 1024 * 1024;
|
|
31
56
|
var ACCEPTED_UPLOAD_MIME = ["image/jpeg", "image/png", "application/pdf"];
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
)
|
|
57
|
+
var UPLOAD_URL_PROTOCOL = /^https$/;
|
|
58
|
+
var UPLOAD_URL_HOSTNAME = /^(?!localhost$)(?!(\d{1,3}\.){3}\d{1,3}$)[a-z0-9.-]+$/i;
|
|
59
|
+
var fileUploadField = requiredObject({
|
|
60
|
+
url: optionalField(
|
|
61
|
+
zod.z.url({
|
|
62
|
+
protocol: UPLOAD_URL_PROTOCOL,
|
|
63
|
+
hostname: UPLOAD_URL_HOSTNAME,
|
|
64
|
+
error: "URL do arquivo inv\xE1lida"
|
|
65
|
+
})
|
|
66
|
+
),
|
|
67
|
+
mime: zod.z.enum(ACCEPTED_UPLOAD_MIME, { error: "Formato deve ser JPEG, PNG ou PDF" }),
|
|
68
|
+
sizeBytes: requiredNumber("Tamanho do arquivo inv\xE1lido").int("Tamanho do arquivo deve ser um n\xFAmero inteiro").positive("Tamanho do arquivo deve ser positivo").max(MAX_UPLOAD_BYTES, "Arquivo deve ter no m\xE1ximo 5MB")
|
|
69
|
+
});
|
|
42
70
|
|
|
43
71
|
// src/shared/enums/nature-of-occupation-type.ts
|
|
44
72
|
var NatureOfOccupationTypeEnum = enumField(["autonomo", "clt", "aposentado", "empresario"]);
|
|
@@ -76,7 +104,11 @@ var CommunionRegimeEnum = enumField([
|
|
|
76
104
|
// src/shared/enums/document-type.ts
|
|
77
105
|
var DocumentTypeEnum = enumField([
|
|
78
106
|
"documento_de_identidade",
|
|
79
|
-
"carteira_nacional_de_habilita\xE7\xE3o"
|
|
107
|
+
"carteira_nacional_de_habilita\xE7\xE3o",
|
|
108
|
+
// Exigido pela RN-015 para nacionalidade estrangeira. Sem este membro a
|
|
109
|
+
// regra seria insatisfazível: todo schema é .strict() com type_doc
|
|
110
|
+
// restrito a este enum.
|
|
111
|
+
"registro_de_estrangeiro"
|
|
80
112
|
]);
|
|
81
113
|
|
|
82
114
|
// src/shared/enums/nationality.ts
|
|
@@ -150,7 +182,10 @@ var PATTERNS = {
|
|
|
150
182
|
cep: /^\d{8}$/,
|
|
151
183
|
phoneBR: /^\d{11}$/,
|
|
152
184
|
email: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
153
|
-
dateDMY: /^\d{2}\/\d{2}\/\d{4}
|
|
185
|
+
dateDMY: /^\d{2}\/\d{2}\/\d{4}$/,
|
|
186
|
+
// Formato do RNE, exigido pela RN-015 para nacionalidade estrangeira.
|
|
187
|
+
rneNumber: /^[A-Za-z0-9]+$/
|
|
188
|
+
};
|
|
154
189
|
|
|
155
190
|
// src/shared/regex/validators.ts
|
|
156
191
|
function onlyDigits(value) {
|
|
@@ -267,22 +302,22 @@ function parseBRLCurrency(value) {
|
|
|
267
302
|
if (typeof value !== "string") {
|
|
268
303
|
return value;
|
|
269
304
|
}
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
305
|
+
const normalized = value.replace(/R\$/gi, "").replace(/\s/g, "").replace(/\./g, "").replace(",", ".");
|
|
306
|
+
if (normalized === "") {
|
|
272
307
|
return void 0;
|
|
273
308
|
}
|
|
274
|
-
const normalized = trimmed.replace(/R\$/gi, "").replace(/\s/g, "").replace(/\./g, "").replace(",", ".");
|
|
275
309
|
const parsed = Number(normalized);
|
|
276
310
|
return Number.isNaN(parsed) ? value : parsed;
|
|
277
311
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
);
|
|
282
|
-
zod.z.
|
|
312
|
+
function brlAmount() {
|
|
313
|
+
return requiredNumber("Valor monet\xE1rio inv\xE1lido").positive("Valor deve ser positivo");
|
|
314
|
+
}
|
|
315
|
+
var currencySchema = zod.z.preprocess(parseBRLCurrency, brlAmount());
|
|
316
|
+
var optionalCurrencySchema = zod.z.preprocess(parseBRLCurrency, brlAmount().optional());
|
|
317
|
+
requiredNumber("Valor num\xE9rico inv\xE1lido").int("Deve ser um n\xFAmero inteiro").min(1, "M\xEDnimo 1").max(28, "M\xE1ximo 28");
|
|
283
318
|
var formalizationExtras = {
|
|
284
319
|
voucher_local_installation_address: fileUploadField,
|
|
285
|
-
proof_kinship_type: ProofKinshipTypeEnum
|
|
320
|
+
proof_kinship_type: optionalField(ProofKinshipTypeEnum),
|
|
286
321
|
proof_kinship: fileUploadField.optional(),
|
|
287
322
|
document_front_upload: fileUploadField,
|
|
288
323
|
document_back_upload: fileUploadField,
|
|
@@ -317,7 +352,7 @@ function applyPartnerRefinement(data, ctx) {
|
|
|
317
352
|
const isEmpty = value === void 0 || value === null || typeof value === "string" && value.trim().length === 0;
|
|
318
353
|
if (isEmpty) {
|
|
319
354
|
ctx.addIssue({
|
|
320
|
-
code:
|
|
355
|
+
code: "custom",
|
|
321
356
|
path: [field],
|
|
322
357
|
message: "Campo obrigat\xF3rio para o estado civil informado"
|
|
323
358
|
});
|
|
@@ -331,25 +366,54 @@ function applyCommonRefinements(data, ctx) {
|
|
|
331
366
|
}
|
|
332
367
|
if (!data.proof_kinship_type) {
|
|
333
368
|
ctx.addIssue({
|
|
334
|
-
code:
|
|
369
|
+
code: "custom",
|
|
335
370
|
path: ["proof_kinship_type"],
|
|
336
371
|
message: "Tipo de comprovante \xE9 obrigat\xF3rio quando a conta est\xE1 em nome de terceiro"
|
|
337
372
|
});
|
|
338
373
|
}
|
|
339
374
|
if (!data.proof_kinship) {
|
|
340
375
|
ctx.addIssue({
|
|
341
|
-
code:
|
|
376
|
+
code: "custom",
|
|
342
377
|
path: ["proof_kinship"],
|
|
343
378
|
message: "Documento de v\xEDnculo \xE9 obrigat\xF3rio quando a conta est\xE1 em nome de terceiro"
|
|
344
379
|
});
|
|
345
380
|
}
|
|
346
381
|
}
|
|
382
|
+
var FOREIGN_DOCUMENT_TYPE = "registro_de_estrangeiro";
|
|
383
|
+
function applyForeignDocumentRefinement(data, ctx) {
|
|
384
|
+
const nationality = data.nationality;
|
|
385
|
+
const isForeign = typeof nationality === "string" && nationality.toLowerCase() !== NATIONALITY_BRAZIL;
|
|
386
|
+
if (!isForeign || !("type_doc" in data)) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
if (data.type_doc !== FOREIGN_DOCUMENT_TYPE) {
|
|
390
|
+
ctx.addIssue({
|
|
391
|
+
code: "custom",
|
|
392
|
+
path: ["type_doc"],
|
|
393
|
+
message: "Para nacionalidade estrangeira, o documento deve ser Registro de Estrangeiro (RNE)"
|
|
394
|
+
});
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (typeof data.doc === "string" && !PATTERNS.rneNumber.test(data.doc)) {
|
|
398
|
+
ctx.addIssue({
|
|
399
|
+
code: "custom",
|
|
400
|
+
path: ["doc"],
|
|
401
|
+
message: "RNE deve conter apenas letras e n\xFAmeros"
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function isRecord(data) {
|
|
406
|
+
return typeof data === "object" && data !== null;
|
|
407
|
+
}
|
|
347
408
|
function applyPfRefinements(data, ctx) {
|
|
409
|
+
if (!isRecord(data)) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
348
412
|
applyCommonRefinements(data, ctx);
|
|
349
413
|
applyPartnerRefinement(data, ctx);
|
|
350
414
|
if ("nature_of_occupation" in data && typeof data.nature_of_occupation === "string" && OCCUPATIONS_REQUIRING_CNPJ.includes(data.nature_of_occupation) && !data.cnpj_proprietary) {
|
|
351
415
|
ctx.addIssue({
|
|
352
|
-
code:
|
|
416
|
+
code: "custom",
|
|
353
417
|
path: ["cnpj_proprietary"],
|
|
354
418
|
message: "CNPJ do propriet\xE1rio \xE9 obrigat\xF3rio para esta ocupa\xE7\xE3o"
|
|
355
419
|
});
|
|
@@ -358,16 +422,32 @@ function applyPfRefinements(data, ctx) {
|
|
|
358
422
|
const years = yearsSinceDMY(data.doc_issue_date);
|
|
359
423
|
if (years !== null && years > RG_MAX_EMISSION_YEARS) {
|
|
360
424
|
ctx.addIssue({
|
|
361
|
-
code:
|
|
425
|
+
code: "custom",
|
|
362
426
|
path: ["doc_issue_date"],
|
|
363
427
|
message: `RG deve ter no m\xE1ximo ${RG_MAX_EMISSION_YEARS} anos de emiss\xE3o`
|
|
364
428
|
});
|
|
365
429
|
}
|
|
366
430
|
}
|
|
431
|
+
applyForeignDocumentRefinement(data, ctx);
|
|
367
432
|
}
|
|
433
|
+
function applyPjRefinements(data, ctx) {
|
|
434
|
+
if (!isRecord(data)) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
applyCommonRefinements(data, ctx);
|
|
438
|
+
}
|
|
439
|
+
function onlyUnknownKeysAborted(payload) {
|
|
440
|
+
return payload.aborted !== true && !payload.issues.some((issue) => issue.continue !== true && issue.code !== "unrecognized_keys");
|
|
441
|
+
}
|
|
442
|
+
var pfRefinement = zod.z.superRefine(applyPfRefinements, {
|
|
443
|
+
when: onlyUnknownKeysAborted
|
|
444
|
+
});
|
|
445
|
+
zod.z.superRefine(applyPjRefinements, {
|
|
446
|
+
when: onlyUnknownKeysAborted
|
|
447
|
+
});
|
|
368
448
|
|
|
369
449
|
// src/domains/financing/formalization/schemas/UnifiedPFSchema.ts
|
|
370
|
-
var unifiedPfObject =
|
|
450
|
+
var unifiedPfObject = requiredObject({
|
|
371
451
|
name: textField(),
|
|
372
452
|
cep: cepSchema,
|
|
373
453
|
cpf: cpfSchema,
|
|
@@ -375,12 +455,12 @@ var unifiedPfObject = zod.z.object({
|
|
|
375
455
|
birth_date: birthDateSchema,
|
|
376
456
|
number: textField(),
|
|
377
457
|
sex: SexEnum,
|
|
378
|
-
complement: textField(15)
|
|
458
|
+
complement: optionalField(textField(15)),
|
|
379
459
|
mother_name: textField(),
|
|
380
460
|
district: textField(),
|
|
381
461
|
energy_account_in_requester_name: YesOrNoEnum,
|
|
382
462
|
city: textField(),
|
|
383
|
-
energy_bill_owner_document: cpfCnpjSchema
|
|
463
|
+
energy_bill_owner_document: optionalField(cpfCnpjSchema),
|
|
384
464
|
state: UfEnum,
|
|
385
465
|
nationality: NationalityEnum.default(NATIONALITY_BRAZIL),
|
|
386
466
|
cellphone: phoneBRSchema,
|
|
@@ -392,28 +472,28 @@ var unifiedPfObject = zod.z.object({
|
|
|
392
472
|
issuing_body: textField(6),
|
|
393
473
|
doc_issue_date: issueDateSchema,
|
|
394
474
|
residence_situation: ResidenceTypeEnum,
|
|
395
|
-
months_in_residence: integerField
|
|
475
|
+
months_in_residence: optionalField(integerField),
|
|
396
476
|
civil_status: CivilStatusEnum,
|
|
397
477
|
uf_naturalness: UfEnum,
|
|
398
|
-
naturalness: textField()
|
|
478
|
+
naturalness: optionalField(textField()),
|
|
399
479
|
nature_of_occupation: NatureOfOccupationTypeEnum,
|
|
400
|
-
company_time: numberField
|
|
401
|
-
cnpj_proprietary: cnpjSchema
|
|
402
|
-
equity_value:
|
|
480
|
+
company_time: optionalField(numberField),
|
|
481
|
+
cnpj_proprietary: optionalField(cnpjSchema),
|
|
482
|
+
equity_value: optionalCurrencySchema,
|
|
403
483
|
emitting_state: UfEnum,
|
|
404
484
|
pep_relationship: YesOrNoEnum,
|
|
405
|
-
social_name: textField()
|
|
406
|
-
partner_name: textField()
|
|
407
|
-
partner_birth: dateDMYSchema
|
|
408
|
-
partner_type_doc: DocumentTypeEnum
|
|
409
|
-
partner_doc: textField()
|
|
410
|
-
partner_cpf: cpfSchema
|
|
411
|
-
partner_city: textField()
|
|
412
|
-
communion_regime: CommunionRegimeEnum
|
|
413
|
-
rural_area: textField(3)
|
|
485
|
+
social_name: optionalField(textField()),
|
|
486
|
+
partner_name: optionalField(textField()),
|
|
487
|
+
partner_birth: optionalField(dateDMYSchema),
|
|
488
|
+
partner_type_doc: optionalField(DocumentTypeEnum),
|
|
489
|
+
partner_doc: optionalField(textField()),
|
|
490
|
+
partner_cpf: optionalField(cpfSchema),
|
|
491
|
+
partner_city: optionalField(textField()),
|
|
492
|
+
communion_regime: optionalField(CommunionRegimeEnum),
|
|
493
|
+
rural_area: optionalField(textField(3)),
|
|
414
494
|
...formalizationExtras
|
|
415
495
|
});
|
|
416
|
-
var unifiedPfSchema = unifiedPfObject.strict().
|
|
496
|
+
var unifiedPfSchema = unifiedPfObject.strict().check(pfRefinement);
|
|
417
497
|
|
|
418
498
|
exports.unifiedPfObject = unifiedPfObject;
|
|
419
499
|
exports.unifiedPfSchema = unifiedPfSchema;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { unifiedPfObject, unifiedPfSchema } from '../../../chunk-
|
|
2
|
-
import '../../../chunk-
|
|
3
|
-
import '../../../chunk-
|
|
1
|
+
export { unifiedPfObject, unifiedPfSchema } from '../../../chunk-K3QXEL6M.mjs';
|
|
2
|
+
import '../../../chunk-QEPJ2RLU.mjs';
|
|
3
|
+
import '../../../chunk-CJSJ3VDW.mjs';
|