I am trying to validate an input field where the user must enter a valid email address. The validation works fine but changing the border color whether the value is valid or not is not working. Is this a bug? or am I missing something in my setup? I set the border value to the following formula:
IF(!IS_EMPTY(self.value) && IS_EMAIL(self.value), theme.$colorContentSubdued, "red")
The border is always red even after I enter a valid email address.
Another observation is that it seems the formula editor considers self.value as a number and not text since I can see a warning “Number type is not assignable to text type”. Not sure this is true since self.value of the input text should be text and not number.
I replicated this and seem to be getting the same results, something is off with the
self.value. I’ll get this checked out more closely, thanks for pointing it out!
As a workaround, maybe adding STRING() to your formula would help, at least it gets the warning away:
IF(!IS_EMPTY(STRING(self.value)) && IS_EMAIL(STRING(self.value)), theme.$colorContentSubdued, "red")
Or as another option, if you have bound the value of the input field to a variable, maybe using that variable instead of
self.value in the formula would help also.
Let me know how these work out!
Hi Cecilia, unfortunately this did not work.
Hmm, before we get the
self.value issue sorted, have you bound any variable to the value of that input field? Maybe using that instead of
self.value in the formula could be a workaround for the time being.
The input field is part of a component so I cannot validate using the bound value. The validation is built as part of the component so we need to to use self.value.
I just tried this again, and it seems to be working now with the formula you originally posted, even though the editor complains about “Number type is not assignable to text type”. Are you still experiencing this issue?
It is working now. Thanks for your help.