Clarify `ignoreBlank` with `presence` validator
sumeetattree opened this issue · comments
Sumeet Attree commented
Environment
- Ember Version: 3.6.0
- Ember CLI Version: 3.6.0
- Ember CP Validations Version: 4.0.0-beta.5
I would have expected ignoreBlank: true
to consider ''
as a valid value. But apparently it isn't. What was the original intention behind ignoreBlank
? I was expecting something like rails, where ignoreBlank
(allowBlank: true
) to actually consider ''
value as a valid value.
Edit:
// Shouldn't this line:
let _isPresent = ignoreBlank ? isPresent(v) : !isEmpty(v);
// be this short circuit instead?
if (ignoreBlank === true && v == '') {
return true;
}
Kevin C commented
I think the naming is confusing. I think what it means is that all the following will be considered invalid:
''
' '
I think it is intended to essentially treat whitespace/empty string as empty/invalid.