invalid
Prop Evaluation on Input
#3252
Unanswered
jacobdaddario
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Howdy!
I've been playing around with the HeadlessUI package for the first time via the Catalyst UI kit, and I just ran into an interesting stumbling block. I was following this Inertia guide while using
inertia-rails
, and I implemented code just as they had in the example. In the example, they do the following:In that example, error statements are rendered conditionally by using the truthiness of
errors.first_name
when present in combination with that fact that logical statements return the last evaluated statement when true. Ruby has this same behavior, and it seems to be semantic enough for the docs of a big framework, so I attempted to use the same technique elsewhere.In my code, I did roughly this, but with irrelevant details omitted.
The thought process was that since
undefined
is falsey, it will only be marked as invalid whenerrors.first_name
is present, since a populated string is truthy. To my surprise, this didn't work. Instead, I had to do the following.I'm not sure if this is considered bugged behavior, so I wanted to open a discussion here as I've heard Adam discuss the use of these threads before. Hopefully this can help confirm if this behavior is intended or not.
Beta Was this translation helpful? Give feedback.
All reactions