dbms/app/Validations/UrlRules.php
2025-05-27 15:17:35 +09:00

21 lines
528 B
PHP

<?php
namespace App\Validations;
class UrlRules
{
/**
* 유효한 도메인인지 확인
*/
public function valid_domain(string $str, string $fields, array $data): bool
{
// 기본적인 정규식 검사 (예: example.com, sub.example.co.kr)
if (!preg_match('/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i', $str)) {
return false;
}
// 실제 DNS 확인도 하고 싶다면 (옵션)
// return checkdnsrr($str, 'A') || checkdnsrr($str, 'AAAA') || checkdnsrr($str, 'MX');
return true;
}
}