adopted-ember-addons / ember-cp-validations

Ember computed property based validations

Home Page:https://adopted-ember-addons.github.io/ember-cp-validations/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clarify `ignoreBlank` with `presence` validator

sumeetattree opened this issue · comments

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;
  }

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.