Project

General

Profile

Bug #12078

'List' validation for Smart Class params should work for any string coercible value

Added by Jitendra Yejare almost 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Smart Variables
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Description of problem:
After Overriding the value of Smart class Parameter and validating the new default value with validator type 'list' fails.

Version-Release number of selected component (if applicable):
foreman-1.10.0-0.develop.201510011619git0033595.el7.noarch
foreman-release-scl-1-1.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Override the default value of a smart class parameter.
2. Select the key type as array/string.
3. Give new default value as [1]/1. (Just an example, anything can be provided)
4. In Optional Input Validator, Select validator type as list.
5. In Validator Rule, give some list of values in which the new default value should be present. In my case its [1,2].
6. Try to submit this change.

Actual results:
1. Validation Failed.
2. Not allowing to submit the change and labelling '[1] is not one of [1,2]' or '1 is not one of [1,2]' for Default Value field.

Expected results:
Should be allowed to submit the change and validation should pass as obvious in above case.

Validation Failed.png View Validation Failed.png 133 KB Jitendra Yejare, 10/07/2015 03:13 AM
Validation%20failed

Associated revisions

Revision baaf6b49 (diff)
Added by Ori Rabin almost 4 years ago

Fixes #12078 - list validator in smart class parameters validates any string coercible value

Revision 9174d8a3 (diff)
Added by Ori Rabin almost 4 years ago

Fixes #12078 - list validator in smart class parameters validates any string coercible value

(cherry picked from commit baaf6b49271f7f5035cb01773723135d12afc5e1)

History

#1 Updated by Dominic Cleal almost 4 years ago

  • Priority changed from High to Normal

The list validator shouldn't contain brackets, unless you're trying to validate their presence, i.e. [1

Using a basic validator against an array wouldn't work. Do you expect it to validate every element? Recursively? This is a feature request, not a bug.

#2 Updated by Dominic Cleal almost 4 years ago

  • Status changed from New to Need more information

#3 Updated by Jitendra Yejare almost 4 years ago

Ok. Got it.
I tried one more scenario here:
Key type as 'Integer' & default value 1 with Validator Type as 'list' & Validator rule as 1,2 (without brackets). This fails saying '1 is not one of 1,2'.
But It works if Key Type set to 'String with Validator type 'list' and rule 1,2 (without brackets).

#4 Updated by The Foreman Bot almost 4 years ago

  • Status changed from Need more information to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2788 added
  • Pull request deleted ()

#5 Updated by Daniel Lobato Garcia almost 4 years ago

  • Subject changed from In Smart Class Parameter, the validation for validator type 'list' is not working as expected. to 'List' validation for Smart Class params should work for any string coercible value

I'll rephrase the title so that it matches what the pull request fixes.

#6 Updated by Dominic Cleal almost 4 years ago

  • Legacy Backlogs Release (now unused) set to 63

#7 Updated by Ori Rabin almost 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF