0 Replies Latest reply on Oct 8, 2009 12:53 PM by jwoo2

    Validator expected behaviour




      I have been using validators to validate my form items and I have a question in the expected behaviour of the Validator object.


      Validators have a "required" property and from my knowledge it's only used at two locations:


      private function validateRequired(value:Object):ValidationResult




          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)
                  return processValidation(value, suppressEvents);
                  // Just return valid
                  return new ValidationResultEvent(ValidationResultEvent.VALID);


      As we can see, in the validate(...) function, processValidation(...) will be called as long as isRealValue(value) is held true. All isRealValue is

          protected function isRealValue(value:Object):Boolean
              return (value != null);

      So if I had a field with text = "" validation still occurs.


      This behaviour is still be acceptable but it raises the question whether "required" is needed in the function and what significance does it have?


      I am not entirely sure whether this should be a bug. I hoping someone on the Flex SDK team will be able to answer my question.