commit 23/09/2025
This commit is contained in:
@@ -181,6 +181,28 @@ class Somecodes {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is a valid IPv4 address.
|
||||
* @param value The string to check.
|
||||
* @return True if the string is a valid IPv4 address, false otherwise.
|
||||
*/
|
||||
fun ValidIPV4(value: String): Boolean{
|
||||
return try{
|
||||
if (ValidString(value)){
|
||||
val parts = value.split(".")
|
||||
if (parts.size != 4) return false
|
||||
for (part in parts){
|
||||
val num = part.toInt()
|
||||
if (num !in 0..255) return false
|
||||
}
|
||||
true
|
||||
} else throw Exception()
|
||||
|
||||
} catch (_: Exception){
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is a valid date in the format "dd-MM-yyyy".
|
||||
* This format is used for log HTML files.
|
||||
|
||||
Reference in New Issue
Block a user