Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-16714

Validator. Credit Card Validator does not work properly when property 'required' is false

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Adobe Flex SDK 3.1 (Release)
    • None
    • Validators
    • Affected OS(s): Windows
      Browser: Internet Explorer 6.x
      Language Found: English

    Description

      Steps to reproduce:
      1. Application code:
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Form>
      <mx:FormItem label="Account Number">
      <mx:TextInput id="ti" width="200"/>
      </mx:FormItem>
      <mx:FormItem>
      <mx:Button id="btn" label="Submit" click="submit(event)"/>
      </mx:FormItem>
      </mx:Form>
      <mx:CreditCardValidator
      id="ccV"
      required="false"
      cardNumberSource="

      {ti}

      "
      cardNumberProperty="text"
      cardTypeSource="

      {cardType}

      "
      cardTypeProperty="type"
      allowedFormatChars=""
      invalid="_valid = false;"
      valid="_valid = true;"/>

      <mx:Script>
      <![CDATA[

      import mx.controls.Alert;
      [Bindable]
      private var cardType:Object =

      {type:"American Express"}

      ;

      private var _valid:Boolean;

      private function submit(event:MouseEvent):void

      { ccV.validate(); Alert.show(_valid.toString()); }


      ]]
      >
      </mx:Script>
      </mx:Application>

      2. Set ccv property 'required' to false. This means that validator should consider empty input as valid.
      3. Launch application
      4. Do not enter any input. Click on Submit button.
      5. See the value on the Alert box.

      Actual Results:
      1. Alert box shows 'false'.

      The validator.as code in my sdk has a function per below:

      public function validate(
      value:Object = null,
      suppressEvents:Boolean = false):ValidationResultEvent
      {
      if (value == null)
      value = getValueFromSource();

      // if required flag is true and there is no value
      // we need to generate a required field error
      if (isRealValue(value) || required) <<<<<<< *********** THIS SHOULD BE 'AND' INSTEAD OF 'OR' *****************

      { return processValidation(value, suppressEvents); }

      else

      { // Just return valid return new ValidationResultEvent(ValidationResultEvent.VALID); }

      }

      Because of the existing OR condition, the logic flows to processValidation even though required is false.

      Expected Results:
      1. Alert box should show 'true'. Since the ccV property 'required' is set to false, I expect the validator to not validate 'empty' textinput.

      Workaround (if any):

      Attachments

        Activity

          People

            Unassigned Unassigned
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: