Hi everyone, I'm having a hard time to validate an...
# compose-ios
r
Hi everyone, I'm having a hard time to validate an email in a KMP/CMP project in the iOS target (Kotlin: 2.1.20 Compose: 1.8.0-rc01). I have different ways how to solve it for the other platforms (android, desktop, wasmJs), but I didn't found a way to make it work on iOS. At the moment I'm back to just Regex, but not even this simple code works, let alone everything the AI suggests using iOS classes from the foundation package, lol. When I just return 'true' everything works as expected. Any clue what I'm doing wrong or what could work?
Copy code
private fun emailAddressRegex(value: String): Boolean {
    val emailRegex = Regex(
        // Very basic regex, without checking for edge case or i18n etc
        "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
    )
    return value.matches(emailRegex)
}
I'm calling it from a BasicTextField using
Copy code
snapshotFlow()
to update the state. Btw, the fix of the BasicSecureTextField works like a charm, thx!
Lol, found it, the email wasn't valid indeed. When I entered an email address into the field (using the BasicTextField) I have a © not an @ symbol. Sorry, was quite hard to spot, luckily my server returned with not a valid email error. 😆 However, I don't know if this is just a problem with the iOS Simulator or a problem with the BasicTextField itself. I'm working on a Swiss keyboard on my laptop and need to do ⌥ L to get an @, normally the @ is on ⌥G. But when I do ⌥G I get a © , while normally the © is ⌥C. I guess this doesn't matter as in reality the user would use the keyboard his device.