'List' validation for Smart Class params should work for any string coercible value
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):
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. (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.
1. Validation Failed.
2. Not allowing to submit the change and labelling ' is not one of [1,2]' or '1 is not one of [1,2]' for Default Value field.
Should be allowed to submit the change and validation should pass as obvious in above case.
Fixes #12078 - list validator in smart class parameters validates any string coercible value
#1 Updated by Dominic Cleal about 7 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.
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.
#3 Updated by Jitendra Yejare about 7 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).
#5 Updated by Daniel Lobato Garcia about 7 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.