This commit is contained in:
Lizandro Guarnizo
2026-05-27 21:39:53 -05:00
parent 2f72d87c3b
commit b317639258
3 changed files with 33 additions and 7 deletions
+9 -2
View File
@@ -26,8 +26,15 @@ try {
$telVal = trim($datos['telefono'] ?? '');
if ($telVal !== '') {
$telDigits = preg_replace('/[^0-9]/', '', $telVal);
if (!preg_match('/^(57)?3\d{9}$/', $telDigits)) {
jsonError('El celular debe comenzar por 3 y tener 10 dígitos. Ej: 3001234567.');
// Número colombiano: 10 dígitos empezando en 3, o con prefijo 57
$esColombia = preg_match('/^57/', $telDigits) || (strlen($telDigits) === 10 && $telDigits[0] === '3');
if ($esColombia) {
$sinPrefijo = preg_replace('/^57/', '', $telDigits);
if (!preg_match('/^3\d{9}$/', $sinPrefijo)) {
jsonError('El celular colombiano debe comenzar por 3 y tener 10 dígitos. Ej: 3001234567.');
}
} elseif (strlen($telDigits) < 6 || strlen($telDigits) > 15) {
jsonError('El número telefónico no es válido (debe tener entre 6 y 15 dígitos).');
}
}
$docVal = trim($datos['numero_documento'] ?? '');