-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidation.gs
More file actions
45 lines (40 loc) · 1.27 KB
/
Copy pathValidation.gs
File metadata and controls
45 lines (40 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* @file Validation.gs
* @description Módulo responsável por validações globais e centralizadas.
* Implementa validação de payloads, tipos de dados e regras de negócio padrão.
*
* @module Validation
* @namespace Validation
* @author EnSiSanar Dev Team
* @version 1.1.0
* @since 2026-04-16
* @requires Logger_System
*/
const Validation = {
_MODULE_NAME: 'Validation',
init: function() {
try {
Logger_System.info(`[${this._MODULE_NAME}] inicializado com sucesso.`);
} catch (e) {
Logger.log(`[Validation.init] Erro ao inicializar: ${e.message}`);
}
},
validatePayload: function (data, required) {
if (!data || typeof data !== 'object') {
return { valid: false, message: 'Payload ausente ou inválido.' };
}
for (const key of required) {
if (data[key] === undefined || data[key] === null || data[key] === '') {
return { valid: false, message: 'Campo obrigatório ausente: ' + key };
}
}
return { valid: true };
},
sanitizeString: function(str) {
if (!str || typeof str !== 'string') return '';
return str.trim().replace(/<[^>]*>?/gm, ''); // Limpa tags HTML básicas
}
};
function initValidation() {
Validation.init();
}