-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wizrad: add condition to useHostnameValidation in case of empty string #2872
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #2872 +/- ##
=======================================
Coverage 82.09% 82.09%
=======================================
Files 207 207
Lines 23291 23313 +22
Branches 2285 2290 +5
=======================================
+ Hits 19120 19139 +19
- Misses 4144 4147 +3
Partials 27 27
Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, the validation should not appear when there is no hostname.
I’m not sure about the approach, though. In this PR we’re hiding the validation by returning an error object with a fieldname of ‘default’. That technically works and is supported by the HookValidatedInput but it just feels kind of surprising/counter-intuitive.
I think it feels counter-intuitive because <HookValidatedInput>
does not surface validation on pristine state components. So there is already an existing pattern for not displaying validation – that’s what I intuitively would expect to use. In other words, set isPristine to true when the field’s value returns to the default state (in this case, ‘’).
This might be a good opportunity to refactor a little bit. The double nested ternary operator is hard to understand. It definitely does support this ‘feature’ where if the fieldName is ‘default’ then but let’s take a step back and ask… should it? Maybe we can get rid of the nested ternary and the concept of a ‘default’ state. Having to manage both ‘default’ and ‘isPristine’ feels duplicitous.
In all the validation hooks, it only seems to be used in one other place, and there is a comment specifically calling it out as a hacky solution…
Therefore, I am a little hesitant to introduce this new pattern to the code base. I’d prefer refactoring a bit. What do you think?
after some investigation, the solution that I did here https://github.com/osbuild/image-builder-frontend/pull/2844/files#diff-5206f54a601e8c56290e1a412fbf3f35172f16b892c7674852c91b4ea846bcd9R62 |
I saw your comment here #2844 |
7f3c4c0
to
32f8bba
Compare
d861369
to
61d3608
Compare
this adds condition to useHostnameValidation in case of empty string if user decide to delete the value in hostname field
nice catch @regexowl , I am looking at stage, if user delete the value in Blueprint name we should see an error be cecause it's mandatory field, am I wrong? |
this adds condition to useHostnameValidation in case of empty string if user decide to delete the value in hostname field
FIX ISSUE: 2917