mirror of
https://github.com/hykilpikonna/AquaDX.git
synced 2026-08-20 16:24:38 -05:00
fix: allow more rfc5322 special characters in email (#225)
This commit is contained in:
@@ -111,8 +111,10 @@ catch (e: Exception) { 400 - e.message.toString() }
|
||||
fun BodyBuilder.headers(vararg pairs: Pair<String, String>) = headers(HttpHeaders().apply { pairs.forEach { (k, v) -> set(k, v) } })
|
||||
|
||||
// Email validation
|
||||
// Modified from:
|
||||
// https://www.baeldung.com/java-email-validation-regex
|
||||
val emailRegex = "^(?=.{1,64}@)[\\p{L}0-9_-]+(\\.[\\p{L}0-9_-]+)*@[^-][\\p{L}0-9-]+(\\.[\\p{L}0-9-]+)*(\\.[\\p{L}]{2,})$".toRegex()
|
||||
// To include more special characters
|
||||
val emailRegex = "^(?=.{1,64}@)[\\p{L}0-9_!#$%&*+/=?^`{}~-]+(\\.[\\p{L}0-9_!#$%&*+/=?^`{}~-]+)*@[^-][\\p{L}0-9-]+(\\.[\\p{L}0-9-]+)*(\\.[\\p{L}]{2,})$".toRegex()
|
||||
fun Str.isValidEmail(): Bool = emailRegex.matches(this)
|
||||
|
||||
// Global Tools
|
||||
|
||||
Reference in New Issue
Block a user