@Vendeta may be confusing not True
and not False
logic?
this button is not disabled when the two booleans are true, instead it's only disabled when one or the other is true
Do you not want to undo the reversal of your non-negating language?
Yes. That was confusing on purpose, to make a point.
I recommend you rename your variables to be more expressive. Or add additional computed variables to your struct to clearly define what you do, or do not want to see.
Try this in Playgrounds.
// Make your logic clear. Your password matches your validation rules, or it doesn't.
var isInvalidPasswordFormat = false // or true. try both in Playgrounds
// Your phone number passes your validation rules, or it doesn't.
var isInvalidPhoneFormat = false // or true
// Both the password and the phone number are invalid formats, or they're not
var somethingNotValid: Bool {
// somethingNotValid IS TRUE if either
isInvalidPhoneFormat || isInvalidPasswordFormat
}
var messageToUser: String {
// if something is NOT VALID show the first message.
somethingNotValid ? "Phone or Password is not valid." : "Both Phone and Password adhere to formats."
}
// Declare WHAT you want to see. Be very clear!
print( messageToUser )
You can use the computed var somethingNotValid
in the button
's .disabled()
modifier. You're telling SwiftUI that you want the button
disabled if somethingNotValid
. I think this is very clear logic.
Keep Coding
Please return here with your updated code. Share how you solved your issue.