Results 1 to 5 of 5

Thread: Model Validation: don't validate empty strings

    You found a bug! We've classified it as EXTJS-14271 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha Premium Member
    Join Date
    May 2007
    Posts
    100

    Default Model Validation: don't validate empty strings

    Ext version tested:
    • 5.0.0.970


    Description:
    When using Ext.data.validator.Format (or Ext.data.validator.Email) empty strings are considered as invalid. This makes it impossible to validate an optional form field.

    This also applies to other validations.


    Possible Solutions:
    • add config allowEmpty or allowBlank
    • don't validate empty strings at all (if a field is required additional validator should be added)

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Ext JS Premium Member
    Join Date
    Feb 2012
    Location
    Oslo, Norway
    Posts
    8

    Default Still an issue?

    We hit the same issue. Any update on weather this has been resolved in the latest nightly builds?

  4. #4

    Default

    I hope that there will be an official fix for this.
    Meanwhile, here is my workaround:
    Code:
    Ext.define('Protonics.overrides.Ext.data.validator.Format', {
        override: 'Ext.data.validator.Format',
        validate: function(value) {
            if ((value == undefined) || (value == '')) // added by Arvin
                return true;
    
            // below are the original Sencha code:
            var matcher = this.getMatcher(),
                result = matcher && matcher.test(value);
    
            return result ? result : this.getMessage();
        }
    });

  5. #5
    Sencha Premium User
    Join Date
    Dec 2017
    Posts
    1

    Default

    Any update?
    Is there an official fix for this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •