mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-14 23:46:50 +03:00
13 lines
371 B
TypeScript
13 lines
371 B
TypeScript
import { ValidationResult } from './types';
|
|
|
|
export function validateIPV4(ip: string): ValidationResult {
|
|
const ipRegex =
|
|
/^(?:(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/;
|
|
|
|
if (ipRegex.test(ip)) {
|
|
return { valid: true, message: 'Valid' };
|
|
}
|
|
|
|
return { valid: false, message: 'Invalid IP address' };
|
|
}
|