commit 23/09/2025

This commit is contained in:
2025-09-23 13:56:16 +07:00
parent 7c67fe90ee
commit 85ccf05634
8 changed files with 237 additions and 56 deletions

View File

@@ -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.