You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

12 lines
296 B

export function isValidIPv4(str: string) {
const blocks = str.split('.');
if (blocks.length !== 4) return false;
for (const value of blocks) {
const num = parseInt(value, 10);
if (Number.isNaN(value)) return false;
if (num < 0 || num > 255) return false;
}
return true;
}