diff --git a/app/Rules/Webfinger.php b/app/Rules/Webfinger.php new file mode 100644 index 000000000..e91fb9e5e --- /dev/null +++ b/app/Rules/Webfinger.php @@ -0,0 +1,62 @@ += 80) { + return false; + } + + if (empty($domain) || + ! str_contains($domain, '.') || + ! preg_match('/^[a-zA-Z0-9.-]+$/', $domain) || + strlen($domain) >= 255) { + return false; + } + + // Optional: Check if domain resolves (can be enabled for stricter validation) + // return checkdnsrr($domain, 'A') || checkdnsrr($domain, 'AAAA') || checkdnsrr($domain, 'MX'); + + return true; + } + + /** + * Get the validation error message. + * + * @return string + */ + public function message() + { + return 'The :attribute must be a valid WebFinger address (username@domain.tld or @username@domain.tld)'; + } +}