@ssplib/react-components 0.0.214 → 0.0.215
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/components/form/input/Input.js +11 -10
- package/package.json +1 -1
|
@@ -61,48 +61,49 @@ function Input(_a) {
|
|
|
61
61
|
const error = errorData ? true : false;
|
|
62
62
|
const formConfig = Object.assign(Object.assign(Object.assign(Object.assign({}, context === null || context === void 0 ? void 0 : context.formRegister(name, {
|
|
63
63
|
validate: (v, f) => {
|
|
64
|
-
|
|
64
|
+
const value = v !== null && v !== void 0 ? v : '';
|
|
65
|
+
if (value.length <= 0 && props.required)
|
|
65
66
|
return 'Este campo é obrigatório';
|
|
66
67
|
if (type === 'cnpj') {
|
|
67
|
-
if (
|
|
68
|
+
if (value.length < 18 && props.required)
|
|
68
69
|
return 'O CNPJ precisa ter no mínimo 14 dígitos';
|
|
69
70
|
}
|
|
70
71
|
//
|
|
71
72
|
else if (type === 'cpf') {
|
|
72
|
-
if (
|
|
73
|
+
if (value.length < 14 && props.required)
|
|
73
74
|
return 'O CPF precisa ter no mínimo 11 dígitos';
|
|
74
75
|
} //
|
|
75
76
|
else if (type === 'sei') {
|
|
76
|
-
if (
|
|
77
|
+
if (value.length < 22 && props.required)
|
|
77
78
|
return 'O Número SEI precisa ter no mínimo 19 dígitos';
|
|
78
79
|
}
|
|
79
80
|
//
|
|
80
81
|
else if (type === 'cep') {
|
|
81
|
-
if (
|
|
82
|
+
if (value.length < 9 && props.required)
|
|
82
83
|
return 'O CPF precisa ter no mínimo 8 dígitos';
|
|
83
84
|
}
|
|
84
85
|
//
|
|
85
86
|
else if (type === 'input' || type === 'password' || type === 'number') {
|
|
86
|
-
if (
|
|
87
|
+
if (value.length > inputMaxLength)
|
|
87
88
|
return `Limite máximo de ${inputMaxLength} caracteres`;
|
|
88
|
-
if (
|
|
89
|
+
if (value.length < inputMinLength && props.required)
|
|
89
90
|
return `Limite mínimo de ${inputMinLength} caracteres`;
|
|
90
91
|
}
|
|
91
92
|
//
|
|
92
93
|
else if (type === 'email') {
|
|
93
|
-
if (
|
|
94
|
+
if (value.length > 50)
|
|
94
95
|
return 'Limite máximo de 50 caracteres';
|
|
95
96
|
if (!/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/g.test(v) && props.required)
|
|
96
97
|
return 'O e-mail inserido não é valido';
|
|
97
98
|
}
|
|
98
99
|
//
|
|
99
100
|
else if (type === 'cpf_cnpj') {
|
|
100
|
-
if ((
|
|
101
|
+
if ((value.length < 14 || (value.length > 14 && value.length < 18)) && props.required)
|
|
101
102
|
return 'O CPF/CNPJ precisa ter no mínimo 11/14 dígitos';
|
|
102
103
|
}
|
|
103
104
|
//
|
|
104
105
|
else if (type === 'phone') {
|
|
105
|
-
if (
|
|
106
|
+
if (value.length < 14 && props.required)
|
|
106
107
|
return 'O número precisa ter pelo menos 10 dígitos';
|
|
107
108
|
}
|
|
108
109
|
},
|