This is an automated email from the ASF dual-hosted git repository.
harbs pushed a commit to branch feature/validation
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/feature/validation by this
push:
new bf21838 Trimmed down core Validation classes. All this logic should
be in beads.
bf21838 is described below
commit bf21838bafb4dc06d7298807604121e03a4b267e
Author: Harbs <[email protected]>
AuthorDate: Sun Oct 1 09:57:22 2017 +0300
Trimmed down core Validation classes. All this logic should be in beads.
---
.../flex/utils/validation/CreditCardValidator.as | 338 +---------
.../flex/utils/validation/CurrencyValidator.as | 35 +-
.../apache/flex/utils/validation/DateValidator.as | 407 +------------
.../apache/flex/utils/validation/EmailValidator.as | 25 +-
.../org/apache/flex/utils/validation/IValidator.as | 26 -
.../flex/utils/validation/NumberValidator.as | 26 -
.../flex/utils/validation/PhoneNumberValidator.as | 18 +-
.../flex/utils/validation/RegExpValidator.as | 11 -
.../utils/validation/SocialSecurityValidator.as | 20 +-
.../flex/utils/validation/StringValidator.as | 13 -
.../org/apache/flex/utils/validation/Validator.as | 678 ++-------------------
.../flex/utils/validation/ZipCodeValidator.as | 21 +-
12 files changed, 62 insertions(+), 1556 deletions(-)
diff --git
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/CreditCardValidator.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/CreditCardValidator.as
index d367b5b..ca753b1 100644
---
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/CreditCardValidator.as
+++
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/CreditCardValidator.as
@@ -435,40 +435,6 @@ package org.apache.flex.utils.validation
// actualListeners
//----------------------------------
- /**
- * @private
- * Returns either the listener or the source
- * for the cardType and cardNumber subfields.
- */
- override protected function get actualListeners():Array
- {
- var results:Array = [];
-
- var typeResult:Object;
- if (_cardTypeListener)
- typeResult = _cardTypeListener;
- else if (_cardTypeSource)
- typeResult = _cardTypeSource;
-
- results.push(typeResult);
- if (typeResult is IValidatorListener)
-
IValidatorListener(typeResult).validationSubField = "cardType";
-
- var numResult:Object;
- if (_cardNumberListener)
- numResult = _cardNumberListener;
- else if (_cardNumberSource)
- numResult = _cardNumberSource;
-
- results.push(numResult);
- if (numResult is IValidatorListener)
-
IValidatorListener(numResult).validationSubField = "cardNumber";
-
- if (results.length > 0 && listener)
- results.push(listener);
-
- return results;
- }
//--------------------------------------------------------------------------
//
@@ -521,9 +487,7 @@ package org.apache.flex.utils.validation
{
if
(DECIMAL_DIGITS.indexOf(value.charAt(i)) != -1)
{
- var message:String =
resourceManager.getString(
- "validators",
"invalidFormatChars");
- throw new Error(message);
+ throw new
Error(invalidFormatChars);
}
}
}
@@ -539,256 +503,8 @@ package org.apache.flex.utils.validation
//
"validators",
//
"creditCardValidatorAllowedFormatChars");
}
+ public var invalidFormatChars:String;
- //----------------------------------
- // cardNumberListener
- //----------------------------------
-
- /**
- * @private
- * Storage for the cardNumberListener property.
- */
- private var _cardNumberListener:IValidatorListener;
-
- [Inspectable(category="General")]
-
- /**
- * The component that listens for the validation result
- * for the card number subfield.
- * If none is specified, use the value specified
- * to the <code>cardNumberSource</code> property.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get cardNumberListener():IValidatorListener
- {
- return _cardNumberListener;
- }
-
- /**
- * @private
- */
- public function set
cardNumberListener(value:IValidatorListener):void
- {
- if (_cardNumberListener == value)
- return;
-
- removeListenerHandler();
-
- _cardNumberListener = value;
-
- addListenerHandler();
- }
-
- //----------------------------------
- // cardNumberProperty
- //----------------------------------
-
- [Inspectable(category="General")]
-
- /**
- * Name of the card number property to validate.
- * This attribute is optional, but if you specify
- * the <code>cardNumberSource</code> property,
- * you should also set this property.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public var cardNumberProperty:String;
-
- //----------------------------------
- // cardNumberSource
- //----------------------------------
-
- /**
- * @private
- * Storage for the cardNumberSource property.
- */
- private var _cardNumberSource:Object;
-
- [Inspectable(category="General")]
-
- /**
- * Object that contains the value of the card number field.
- * If you specify a value for this property, you must also
specify
- * a value for the <code>cardNumberProperty</code> property.
- * Do not use this property if you set the <code>source</code>
- * and <code>property</code> properties.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get cardNumberSource():Object
- {
- return _cardNumberSource;
- }
-
- /**
- * @private
- */
- public function set cardNumberSource(value:Object):void
- {
- if (_cardNumberSource == value)
- return;
-
- if (value is String)
- {
- var message:String = resourceManager.getString(
- "validators", "CNSAttribute", [ value
]);
- throw new Error(message);
- }
-
- removeListenerHandler();
-
- _cardNumberSource = value;
-
- addListenerHandler();
- }
-
- //----------------------------------
- // cardTypeListener
- //----------------------------------
-
- /**
- * @private
- * Storage for the cardTypeListener property.
- */
- private var _cardTypeListener:IValidatorListener;
-
- [Inspectable(category="General")]
-
- /**
- * The component that listens for the validation result
- * for the card type subfield.
- * If none is specified, then use the value
- * specified to the <code>cardTypeSource</code> property.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get cardTypeListener():IValidatorListener
- {
- return _cardTypeListener;
- }
-
- /**
- * @private
- */
- public function set
cardTypeListener(value:IValidatorListener):void
- {
- if (_cardTypeListener == value)
- return;
-
- removeListenerHandler();
-
- _cardTypeListener = value;
-
- addListenerHandler();
- }
-
- //----------------------------------
- // cardTypeProperty
- //----------------------------------
-
- [Inspectable(category="General")]
-
- /**
- * Name of the card type property to validate.
- * This attribute is optional, but if you specify the
- * <code>cardTypeSource</code> property,
- * you should also set this property.
- *
- * <p>In MXML, valid values are:</p>
- * <ul>
- * <li><code>"American Express"</code></li>
- * <li><code>"Diners Club"</code></li>
- * <li><code>"Discover"</code></li>
- * <li><code>"MasterCard"</code></li>
- * <li><code>"Visa"</code></li>
- * </ul>
- *
- * <p>In ActionScript, you can use the following constants to
set this property:</p>
- *
<p><code>CreditCardValidatorCardType.AMERICAN_EXPRESS</code>,
- * <code>CreditCardValidatorCardType.DINERS_CLUB</code>,
- * <code>CreditCardValidatorCardType.DISCOVER</code>,
- * <code>CreditCardValidatorCardType.MASTER_CARD</code>, and
- * <code>CreditCardValidatorCardType.VISA</code>.</p>
- *
- * @see mx.validators.CreditCardValidatorCardType
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public var cardTypeProperty:String;
-
- //----------------------------------
- // cardTypeSource
- //----------------------------------
-
- /**
- * @private
- * Storage for the cardTypeSource property.
- */
- private var _cardTypeSource:Object;
-
- [Inspectable(category="General")]
-
- /**
- * Object that contains the value of the card type field.
- * If you specify a value for this property, you must also
specify
- * a value for the <code>cardTypeProperty</code> property.
- * Do not use this property if you set the <code>source</code>
- * and <code>property</code> properties.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get cardTypeSource():Object
- {
- return _cardTypeSource;
- }
-
- /**
- * @private
- */
- public function set cardTypeSource(value:Object):void
- {
- if (_cardTypeSource == value)
- return;
-
- if (value is String)
- {
- var message:String = resourceManager.getString(
- "validators", "CTSAttribute", [ value
]);
- throw new Error(message);
- }
-
- removeListenerHandler();
-
- _cardTypeSource = value;
-
- addListenerHandler();
- }
-
-
//--------------------------------------------------------------------------
- //
- // Properties: Errors
- //
-
//--------------------------------------------------------------------------
//----------------------------------
// invalidCharError
@@ -1085,28 +801,6 @@ package org.apache.flex.utils.validation
// "validators",
"wrongTypeError");
}
-
//--------------------------------------------------------------------------
- //
- // Overridden methods
- //
-
//--------------------------------------------------------------------------
-
- /**
- * @private
- */
- override protected function resourcesChanged():void
- {
- super.resourcesChanged();
-
- allowedFormatChars = allowedFormatCharsOverride;
-
- invalidCharError = invalidCharErrorOverride;
- invalidNumberError = invalidNumberErrorOverride;
- noNumError = noNumErrorOverride;
- noTypeError = noTypeErrorOverride;
- wrongLengthError = wrongLengthErrorOverride;
- wrongTypeError = wrongTypeErrorOverride;
- }
/**
* Override of the base class <code>doValidation()</code>
method
@@ -1138,34 +832,6 @@ package org.apache.flex.utils.validation
else
return
CreditCardValidator.validateCreditCard(this, value, null);
}
-
- /**
- * @private
- * Grabs the data for the validator from two different sources
- */
- override protected function getValueFromSource():Object
- {
- var useValue:Boolean = false;
-
- var value:Object = {};
-
- if (cardTypeSource && cardTypeProperty)
- {
- value.cardType =
cardTypeSource[cardTypeProperty];
- useValue = true;
- }
-
- if (cardNumberSource && cardNumberProperty)
- {
- value.cardNumber =
cardNumberSource[cardNumberProperty];
- useValue = true;
- }
-
- if (useValue)
- return value;
- else
- return super.getValueFromSource();
- }
}
}
diff --git
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/CurrencyValidator.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/CurrencyValidator.as
index a30ade0..e7cd006 100644
---
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/CurrencyValidator.as
+++
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/CurrencyValidator.as
@@ -570,10 +570,10 @@ package org.apache.flex.utils.validation
_currencySymbol = value != null ?
value : "$";
// TODO get from resource bundle
- _currencySymbol = value != null ?
- value :
- resourceManager.getString(
- "SharedResources", "currencySymbol");
+ // _currencySymbol = value != null ?
+ // value :
+ // resourceManager.getString(
+ // "SharedResources", "currencySymbol");
}
//----------------------------------
@@ -1280,32 +1280,7 @@ package org.apache.flex.utils.validation
//
//--------------------------------------------------------------------------
- /**
- * @private
- */
- override protected function resourcesChanged():void
- {
- super.resourcesChanged();
-
- alignSymbol = alignSymbolOverride;
- allowNegative = allowNegativeOverride;
- currencySymbol = currencySymbolOverride;
- decimalSeparator = decimalSeparatorOverride;
- maxValue = maxValueOverride;
- minValue = minValueOverride;
- precision = precisionOverride;
- thousandsSeparator = thousandsSeparatorOverride;
-
- currencySymbolError = currencySymbolErrorOverride;
- decimalPointCountError = decimalPointCountErrorOverride;
- exceedsMaxError = exceedsMaxErrorOverride;
- invalidCharError = invalidCharErrorOverride;
- invalidFormatCharsError = invalidFormatCharsErrorOverride;
- lowerThanMinError = lowerThanMinErrorOverride;
- negativeError = negativeErrorOverride;
- precisionError = precisionErrorOverride;
- separationError = separationErrorOverride;
- }
+
/**
* Override of the base class <code>doValidation()</code> method
diff --git
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/DateValidator.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/DateValidator.as
index 20fc1a8..aa32220 100644
---
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/DateValidator.as
+++
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/DateValidator.as
@@ -19,6 +19,7 @@
package org.apache.flex.utils.validation
{
+
// [ResourceBundle("SharedResources")]
// [ResourceBundle("validators")]
@@ -508,71 +509,7 @@ package org.apache.flex.utils.validation
subFields = [ "day", "month", "year" ];
}
-
//--------------------------------------------------------------------------
- //
- // Overridden properties
- //
-
//--------------------------------------------------------------------------
-
- //----------------------------------
- // actualListeners
- //----------------------------------
- /**
- * @private
- * Returns either the listener or the source
- * for the day, month and year subfields.
- */
- override protected function get actualListeners():Array
- {
- var results:Array = [];
-
- var dayResult:Object;
- if (_dayListener)
- dayResult = _dayListener;
- else if (_daySource)
- dayResult = _daySource;
-
- if (dayResult)
- {
- results.push(dayResult);
- if (dayResult is IValidatorListener)
-
IValidatorListener(dayResult).validationSubField = "day";
- }
-
- var monthResult:Object;
- if (_monthListener)
- monthResult = _monthListener;
- else if (_monthSource)
- monthResult = _monthSource;
-
- if (monthResult)
- {
- results.push(monthResult);
- if (monthResult is IValidatorListener)
-
IValidatorListener(monthResult).validationSubField = "month";
- }
-
- var yearResult:Object;
- if (_yearListener)
- yearResult = _yearListener;
- else if (_yearSource)
- yearResult = _yearSource;
-
- if (yearResult)
- {
- results.push(yearResult);
- if (yearResult is IValidatorListener)
-
IValidatorListener(yearResult).validationSubField = "year";
- }
-
- if (results.length > 0 && listener)
- results.push(listener);
- else
- results = results.concat(super.actualListeners);
-
- return results;
- }
//--------------------------------------------------------------------------
//
@@ -625,9 +562,7 @@ package org.apache.flex.utils.validation
{
if
(DECIMAL_DIGITS.indexOf(value.charAt(i)) != -1)
{
- var message:String =
resourceManager.getString(
- "validators",
"invalidFormatChars");
- throw new Error(message);
+ throw new
Error(invalidFormatChars);
}
}
}
@@ -643,49 +578,8 @@ package org.apache.flex.utils.validation
//
"validators",
//
"dateValidatorAllowedFormatChars");
}
+ public var invalidFormatChars:String;
- //----------------------------------
- // dayListener
- //----------------------------------
-
- /**
- * @private
- * Storage for the dayListener property.
- */
- private var _dayListener:IValidatorListener;
-
- [Inspectable(category="General")]
-
- /**
- * The component that listens for the validation result
- * for the day subfield.
- * If none is specified, use the value specified
- * for the <code>daySource</code> property.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get dayListener():IValidatorListener
- {
- return _dayListener;
- }
-
- /**
- * @private
- */
- public function set dayListener(value:IValidatorListener):void
- {
- if (_dayListener == value)
- return;
-
- removeListenerHandler();
-
- _dayListener = value;
-
- addListenerHandler();
- }
//----------------------------------
// dayProperty
@@ -706,57 +600,6 @@ package org.apache.flex.utils.validation
public var dayProperty:String;
//----------------------------------
- // daySource
- //----------------------------------
-
- /**
- * @private
- * Storage for the daySource property.
- */
- private var _daySource:Object;
-
- [Inspectable(category="General")]
-
- /**
- * Object that contains the value of the day field.
- * If you specify a value for this property, you must also
- * specify a value for the <code>dayProperty</code> property.
- * Do not use this property if you set the <code>source</code>
- * and <code>property</code> properties.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get daySource():Object
- {
- return _daySource;
- }
-
- /**
- * @private
- */
- public function set daySource(value:Object):void
- {
- if (_daySource == value)
- return;
-
- if (value is String)
- {
- var message:String = resourceManager.getString(
- "validators", "DSAttribute", [ value ]);
- throw new Error(message);
- }
-
- removeListenerHandler();
-
- _daySource = value;
-
- addListenerHandler();
- }
-
- //----------------------------------
// inputFormat
//----------------------------------
@@ -818,37 +661,6 @@ package org.apache.flex.utils.validation
[Inspectable(category="General")]
- /**
- * The component that listens for the validation result
- * for the month subfield.
- * If none is specified, use the value specified
- * for the <code>monthSource</code> property.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get monthListener():IValidatorListener
- {
- return _monthListener;
- }
-
- /**
- * @private
- */
- public function set monthListener(value:IValidatorListener):void
- {
- if (_monthListener == value)
- return;
-
- removeListenerHandler();
-
- _monthListener = value;
-
- addListenerHandler();
- }
-
//----------------------------------
// monthProperty
//----------------------------------
@@ -868,57 +680,6 @@ package org.apache.flex.utils.validation
public var monthProperty:String;
//----------------------------------
- // monthSource
- //----------------------------------
-
- /**
- * @private
- * Storage for the monthSource property.
- */
- private var _monthSource:Object;
-
- [Inspectable(category="General")]
-
- /**
- * Object that contains the value of the month field.
- * If you specify a value for this property, you must also
specify
- * a value for the <code>monthProperty</code> property.
- * Do not use this property if you set the <code>source</code>
- * and <code>property</code> properties.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get monthSource():Object
- {
- return _monthSource;
- }
-
- /**
- * @private
- */
- public function set monthSource(value:Object):void
- {
- if (_monthSource == value)
- return;
-
- if (value is String)
- {
- var message:String = resourceManager.getString(
- "validators", "MSAttribute", [ value ]);
- throw new Error(message);
- }
-
- removeListenerHandler();
-
- _monthSource = value;
-
- addListenerHandler();
- }
-
- //----------------------------------
// validateAsString
//----------------------------------
@@ -971,118 +732,6 @@ package org.apache.flex.utils.validation
//
"validators", "validateAsString");
}
- //----------------------------------
- // yearListener
- //----------------------------------
-
- /**
- * @private
- * Storage for the yearListener property.
- */
- private var _yearListener:IValidatorListener;
-
- [Inspectable(category="General")]
-
- /**
- * The component that listens for the validation result
- * for the year subfield.
- * If none is specified, use the value specified
- * for the <code>yearSource</code> property.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get yearListener():IValidatorListener
- {
- return _yearListener;
- }
-
- /**
- * @private
- */
- public function set yearListener(value:IValidatorListener):void
- {
- if (_yearListener == value)
- return;
-
- removeListenerHandler();
-
- _yearListener = value;
-
- addListenerHandler();
- }
-
- //----------------------------------
- // yearProperty
- //----------------------------------
-
- [Inspectable(category="General")]
-
- /**
- * Name of the year property to validate.
- * This property is optional, but if you specify the
- * <code>yearSource</code> property, you should also set this
property.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public var yearProperty:String;
-
- //----------------------------------
- // yearSource
- //----------------------------------
-
- /**
- * @private
- * Storage for the yearSource property.
- */
- private var _yearSource:Object;
-
- [Inspectable(category="General")]
-
- /**
- * Object that contains the value of the year field.
- * If you specify a value for this property, you must also
specify
- * a value for the <code>yearProperty</code> property.
- * Do not use this property if you set the <code>source</code>
- * and <code>property</code> properties.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get yearSource():Object
- {
- return _yearSource;
- }
-
- /**
- * @private
- */
- public function set yearSource(value:Object):void
- {
- if (_yearSource == value)
- return;
-
- if (value is String)
- {
- var message:String = resourceManager.getString(
- "validators", "YSAttribute", [ value ]);
- throw new Error(message);
- }
-
- removeListenerHandler();
-
- _yearSource = value;
-
- addListenerHandler();
- }
-
//--------------------------------------------------------------------------
//
// Properties: Errors
@@ -1388,25 +1037,6 @@ package org.apache.flex.utils.validation
//--------------------------------------------------------------------------
/**
- * @private
- */
- override protected function resourcesChanged():void
- {
- super.resourcesChanged();
-
- allowedFormatChars = allowedFormatCharsOverride;
- inputFormat = inputFormatOverride;
- validateAsString = validateAsStringOverride;
-
- invalidCharError = invalidCharErrorOverride;
- wrongLengthError = wrongLengthErrorOverride;
- wrongMonthError = wrongMonthErrorOverride;
- wrongDayError = wrongDayErrorOverride;
- wrongYearError = wrongYearErrorOverride;
- formatError = formatErrorOverride;
- }
-
- /**
* Override of the base class <code>doValidation()</code>
method
* to validate a date.
*
@@ -1437,36 +1067,7 @@ package org.apache.flex.utils.validation
return DateValidator.validateDate(this, value,
null);
}
- /**
- * @private
- * Grabs the data for the validator from three different
sources.
- */
- override protected function getValueFromSource():Object
- {
- var useValue:Boolean = false;
-
- var value:Object = {};
-
- if (daySource && dayProperty)
- {
- value.day = daySource[dayProperty];
- useValue = true;
- }
-
- if (monthSource && monthProperty)
- {
- value.month = monthSource[monthProperty];
- useValue = true;
- }
-
- if (yearSource && yearProperty)
- {
- value.year = yearSource[yearProperty];
- useValue = true;
- }
-
- return useValue ? value : super.getValueFromSource();
- }
+
}
}
diff --git
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/EmailValidator.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/EmailValidator.as
index 509698a..6b63f29 100644
---
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/EmailValidator.as
+++
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/EmailValidator.as
@@ -794,10 +794,10 @@ package org.apache.flex.utils.validation
_tooManyAtSignsError = value != null ?
value : "Your
e-mail address contains too many @ characters.";
// TODO get from resource bundle
- _tooManyAtSignsError = value != null ?
- value :
-
resourceManager.getString(
-
"validators", "tooManyAtSignsError");
+ // _tooManyAtSignsError = value != null ?
+ // value :
+ //
resourceManager.getString(
+ //
"validators", "tooManyAtSignsError");
}
//--------------------------------------------------------------------------
@@ -807,23 +807,6 @@ package org.apache.flex.utils.validation
//--------------------------------------------------------------------------
/**
- * @private
- */
- override protected function resourcesChanged():void
- {
- super.resourcesChanged();
-
- invalidCharError = invalidCharErrorOverride;
- invalidDomainError = invalidDomainErrorOverride;
- invalidIPDomainError = invalidIPDomainErrorOverride;
- invalidPeriodsInDomainError =
invalidPeriodsInDomainErrorOverride;
- missingAtSignError = missingAtSignErrorOverride;
- missingPeriodInDomainError =
missingPeriodInDomainErrorOverride;
- missingUsernameError = missingUsernameErrorOverride;
- tooManyAtSignsError = tooManyAtSignsErrorOverride;
- }
-
- /**
* Override of the base class <code>doValidation()</code>
method
* to validate an e-mail address.
*
diff --git
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/IValidator.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/IValidator.as
index 126af8e..cb12d35 100644
---
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/IValidator.as
+++
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/IValidator.as
@@ -42,32 +42,6 @@ package org.apache.flex.utils.validation
*/
public interface IValidator
{
-
//----------------------------------------------------------------------
- //
- // Properties
- //
-
//----------------------------------------------------------------------
-
- //----------------------------------
- // enabled
- //----------------------------------
-
- /**
- * Property to enable/disable validation process.
- * <p>Setting this value to <code>false</code> will stop the validator
- * from performing validation.
- * When a validator is disabled, it dispatches no events,
- * and the <code>validate()</code> method returns null.</p>
- *
- * @default true
- *
- * @langversion 3.0
- * @playerversion Flash 10.1
- * @playerversion AIR 2.0
- * @productversion Flex 4.5
- */
- function get enabled():Boolean;
- function set enabled(value:Boolean):void;
//----------------------------------------------------------------------
//
diff --git
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/NumberValidator.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/NumberValidator.as
index ca025fa..a7774a7 100644
---
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/NumberValidator.as
+++
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/NumberValidator.as
@@ -1113,32 +1113,6 @@ package org.apache.flex.utils.validation
//--------------------------------------------------------------------------
/**
- * @private
- */
- override protected function resourcesChanged():void
- {
- super.resourcesChanged();
-
- allowNegative = allowNegativeOverride;
- decimalSeparator = decimalSeparatorOverride;
- domain = domainOverride;
- maxValue = maxValueOverride;
- minValue = minValueOverride;
- precision = precisionOverride;
- thousandsSeparator = thousandsSeparatorOverride;
-
- decimalPointCountError = decimalPointCountErrorOverride;
- exceedsMaxError = exceedsMaxErrorOverride;
- integerError = integerErrorOverride;
- invalidCharError = invalidCharErrorOverride;
- invalidFormatCharsError =
invalidFormatCharsErrorOverride;
- lowerThanMinError = lowerThanMinErrorOverride;
- negativeError = negativeErrorOverride;
- precisionError = precisionErrorOverride;
- separationError = separationErrorOverride;
- }
-
- /**
* Override of the base class <code>doValidation()</code>
method
* to validate a number.
*
diff --git
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/PhoneNumberValidator.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/PhoneNumberValidator.as
index 1da074a..bc57c5d 100644
---
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/PhoneNumberValidator.as
+++
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/PhoneNumberValidator.as
@@ -210,9 +210,7 @@ package org.apache.flex.utils.validation
{
if
(DECIMAL_DIGITS.indexOf(value.charAt(i)) != -1)
{
- var message:String =
resourceManager.getString(
- "validators",
"invalidFormatChars");
- throw new Error(message);
+ throw new
Error(invalidFormatChars);
}
}
}
@@ -223,6 +221,8 @@ package org.apache.flex.utils.validation
value : "()-
.+";
}
+ public var invalidFormatChars:String;
+
//----------------------------------
// minDigits
//----------------------------------
@@ -370,18 +370,6 @@ package org.apache.flex.utils.validation
//
//--------------------------------------------------------------------------
- /**
- * @private
- */
- override protected function resourcesChanged():void
- {
- super.resourcesChanged();
-
- allowedFormatChars = allowedFormatCharsOverride;
- minDigits = minDigitsOverride;
- invalidCharError = invalidCharErrorOverride;
- wrongLengthError = wrongLengthErrorOverride;
- }
/**
* Override of the base class <code>doValidation()</code>
method
diff --git
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/RegExpValidator.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/RegExpValidator.as
index 8b34b09..2da3ff0 100644
---
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/RegExpValidator.as
+++
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/RegExpValidator.as
@@ -300,17 +300,6 @@ package org.apache.flex.utils.validation
//--------------------------------------------------------------------------
/**
- * @private
- */
- override protected function resourcesChanged():void
- {
- super.resourcesChanged();
-
- noExpressionError = noExpressionErrorOverride;
- noMatchError = noMatchErrorOverride;
- }
-
- /**
* Override of the base class <code>doValidation()</code> method
* to validate a regular expression.
*
diff --git
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/SocialSecurityValidator.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/SocialSecurityValidator.as
index a8be43e..e33fcb2 100644
---
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/SocialSecurityValidator.as
+++
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/SocialSecurityValidator.as
@@ -219,9 +219,7 @@ package org.apache.flex.utils.validation
{
if
(DECIMAL_DIGITS.indexOf(value.charAt(i)) != -1)
{
- var message:String =
resourceManager.getString(
- "validators",
"invalidFormatChars");
- throw new Error(message);
+ throw new
Error(invalidFormatChars);
}
}
}
@@ -238,6 +236,8 @@ package org.apache.flex.utils.validation
//
"socialSecurityValidatorAllowedFormatChars");
}
+ public var invalidFormatChars:String;
+
//--------------------------------------------------------------------------
//
// Properties: Errors
@@ -397,20 +397,6 @@ package org.apache.flex.utils.validation
//--------------------------------------------------------------------------
/**
- * @private
- */
- override protected function resourcesChanged():void
- {
- super.resourcesChanged();
-
- allowedFormatChars = allowedFormatChars;
-
- invalidCharError = invalidCharErrorOverride;
- wrongFormatError = wrongFormatErrorOverride;
- zeroStartError = zeroStartErrorOverride;
- }
-
- /**
* Override of the base class <code>doValidation()</code>
method
* to validate a Social Security number.
*
diff --git
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/StringValidator.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/StringValidator.as
index 974e747..5b2a7ad 100644
---
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/StringValidator.as
+++
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/StringValidator.as
@@ -337,19 +337,6 @@ package org.apache.flex.utils.validation
//
//--------------------------------------------------------------------------
- /**
- * @private
- */
- override protected function resourcesChanged():void
- {
- super.resourcesChanged();
-
- maxLength = maxLengthOverride;
- minLength = minLengthOverride;
-
- tooLongError = tooLongErrorOverride;
- tooShortError = tooShortErrorOverride;
- }
/**
* Override of the base class <code>doValidation()</code> method
diff --git
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/Validator.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/Validator.as
index cbaec2d..572cc15 100644
---
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/Validator.as
+++
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/Validator.as
@@ -158,7 +158,7 @@ package org.apache.flex.utils.validation
var n:int = validators.length;
for (var i:int = 0; i < n; i++)
{
- var v:IValidator = validators[i] as IValidator;
+ var v:Validator = validators[i] as Validator;
if (v && v.enabled)
{
var resultEvent:ValidationResultEvent = v.validate();
@@ -174,53 +174,6 @@ package org.apache.flex.utils.validation
/**
* @private
*/
- private static function findObjectFromString(doc:Object,
- value:String):Object
- {
- var obj:Object = doc;
- var parts:Array = value.split(".");
-
- var n:int = parts.length;
- for (var i:int = 0; i < n; i++)
- {
- try
- {
- obj = obj[parts[i]];
-
- // There's no guarantee that the objects have
- // already been created when this function fires;
- // for example, in the deferred instantiation case,
- // this function fires before the object for validation
- // has been created.
- if (obj == null)
- {
- //return true;
- }
- }
- catch(error:Error)
- {
- if ((error is TypeError) &&
- (error.message.indexOf("null has no properties") !=
-1))
- {
- var resourceManager:IResourceManager =
- ResourceManager.getInstance();
- var message:String = resourceManager.getString(
- "validators", "fieldNotFound", [ value ]);
- throw new Error(message);
- }
- else
- {
- throw error;
- }
- }
- }
-
- return obj;
- }
-
- /**
- * @private
- */
private static function trimString(str:String):String
{
var startIndex:int = 0;
@@ -257,327 +210,7 @@ package org.apache.flex.utils.validation
public function Validator()
{
super();
-
- // Register as a weak listener for "change" events from
ResourceManager.
- // If Validators registered as a strong listener,
- // they wouldn't get garbage collected.
- // resourceManager.addEventListener(
- // Event.CHANGE, resourceManager_changeHandler, false, 0,
true);
-
- resourcesChanged();
- }
-
-
//--------------------------------------------------------------------------
- //
- // Variables
- //
-
//--------------------------------------------------------------------------
-
-
-
//--------------------------------------------------------------------------
- //
- // Properties
- //
-
//--------------------------------------------------------------------------
-
- //----------------------------------
- // actualTrigger
- //----------------------------------
-
- /**
- * Contains the trigger object, if any,
- * or the source object. Used to determine the listener object
- * for the <code>triggerEvent</code>.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- protected function get actualTrigger():IEventDispatcher
- {
- if (_trigger)
- return _trigger;
-
- else if (_source)
- return _source as IEventDispatcher;
-
- return null;
- }
-
- //----------------------------------
- // actualListeners
- //----------------------------------
-
- /**
- * Contains an Array of listener objects, if any,
- * or the source object. Used to determine which object
- * to notify about the validation result.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- protected function get actualListeners():Array
- {
- var result:Array = [];
-
- if (_listener)
- result.push(_listener);
-
- else if (_source)
- result.push(_source);
-
- return result;
- }
-
- //----------------------------------
- // enabled
- //----------------------------------
-
- /**
- * @private
- * Storage for the enabled property.
- */
- private var _enabled:Boolean = true;
-
- [Inspectable(category="General", defaultValue="true")]
-
- /**
- * Setting this value to <code>false</code> will stop the validator
- * from performing validation.
- * When a validator is disabled, it dispatch no events,
- * and the <code>validate()</code> method returns null.
- *
- * @default true
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get enabled():Boolean
- {
- return _enabled;
- }
-
- /**
- * @private
- */
- public function set enabled(value:Boolean):void
- {
- _enabled = value;
- }
-
- //----------------------------------
- // listener
- //----------------------------------
-
- /**
- * @private
- * Storage for the listener property.
- */
- private var _listener:Object;
-
- [Inspectable(category="General")]
-
- /**
- * Specifies the validation listener.
- *
- * <p>If you do not specify a listener,
- * Flex uses the value of the <code>source</code> property.
- * After Flex determines the source component,
- * it changes the border color of the component,
- * displays an error message for a failure,
- * or hides any existing error message for a successful
validation.</p>
- *
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
-
- /* This behavior has been removed.
- * <p>If Flex does not find an appropriate listener,
- * validation errors propagate to the Application object, causing Flex
- * to display an Alert box containing the validation error message.</p>
- *
- * <p>Specifying <code>this</code> causes the validation error
- * to propagate to the Application object,
- * and displays an Alert box containing the validation error
message.</p>
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get listener():Object
- {
- return _listener;
- }
-
- /**
- * @private
- */
- public function set listener(value:Object):void
- {
- removeListenerHandler();
- _listener = value;
- addListenerHandler();
- }
-
- //----------------------------------
- // property
- //----------------------------------
-
- /**
- * @private
- * Storage for the property property.
- */
- private var _property:String;
-
- [Inspectable(category="General")]
-
- /**
- * A String specifying the name of the property
- * of the <code>source</code> object that contains
- * the value to validate.
- * The property is optional, but if you specify <code>source</code>,
- * you should set a value for this property as well.
- *
- * @default null
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get property():String
- {
- return _property;
- }
-
- /**
- * @private
- */
- public function set property(value:String):void
- {
- _property = value;
- }
-
- //----------------------------------
- // required
- //----------------------------------
-
- [Inspectable(category="General", defaultValue="true")]
-
- /**
- * If <code>true</code>, specifies that a missing or empty
- * value causes a validation error.
- *
- * @default true
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public var required:Boolean = true;
-
- //----------------------------------
- // resourceManager
- //----------------------------------
-
- /**
- * @private
- * Storage for the resourceManager property.
- */
- private var _resourceManager:IResourceManager =
ResourceManager.getInstance();
-
- /**
- * @private
- * This metadata suppresses a trace() in PropertyWatcher:
- * "warning: unable to bind to property 'resourceManager' ..."
- */
- [Bindable("unused")]
-
- /**
- * @copy mx.core.UIComponent#resourceManager
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- protected function get resourceManager():IResourceManager
- {
- return _resourceManager;
- }
-
- //----------------------------------
- // source
- //----------------------------------
-
- /**
- * @private
- * Storage for the source property.
- */
- private var _source:Object;
-
- [Inspectable(category="General")]
-
- /**
- * Specifies the object containing the property to validate.
- * Set this to an instance of a component or a data model.
- * You use data binding syntax in MXML to specify the value.
- * This property supports dot-delimited Strings
- * for specifying nested properties.
- *
- * If you specify a value to the <code>source</code> property,
- * then you should specify a value to the <code>property</code>
- * property as well.
- * The <code>source</code> property is optional.
- *
- * @default null
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get source():Object
- {
- return _source;
- }
-
- /**
- * @private
- */
- public function set source(value:Object):void
- {
- if (_source == value)
- return;
-
- if (value is String)
- {
- var message:String = resourceManager.getString(
- "validators", "SAttribute", [ value ]);
- throw new Error(message);
- }
-
- // Remove the listener from the old source.
- removeTriggerHandler();
- removeListenerHandler();
-
- _source = value;
-
- // Listen for the trigger event on the new source.
- addTriggerHandler();
- addListenerHandler();
}
-
//----------------------------------
// subFields
//----------------------------------
@@ -602,90 +235,8 @@ package org.apache.flex.utils.validation
*/
protected var subFields:Array = [];
- //----------------------------------
- // trigger
- //----------------------------------
-
- /**
- * @private
- * Storage for the trigger property.
- */
- private var _trigger:IEventDispatcher;
-
- [Inspectable(category="General")]
- /**
- * Specifies the component generating the event that triggers the
validator.
- * If omitted, by default Flex uses the value of the
<code>source</code> property.
- * When the <code>trigger</code> dispatches a
<code>triggerEvent</code>,
- * validation executes.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get trigger():IEventDispatcher
- {
- return _trigger;
- }
- /**
- * @private
- */
- public function set trigger(value:IEventDispatcher):void
- {
- removeTriggerHandler();
- _trigger = value;
- addTriggerHandler();
- }
-
- //----------------------------------
- // triggerEvent
- //----------------------------------
-
- /**
- * @private
- * Storage for the triggerEvent property.
- */
- //TODO What is this for (changed the old value to a literal to make
error go away)?
- private var _triggerEvent:String = "valueCommit";
-
- [Inspectable(category="General")]
-
- /**
- * Specifies the event that triggers the validation.
- * If omitted, Flex uses the <code>valueCommit</code> event.
- * Flex dispatches the <code>valueCommit</code> event
- * when a user completes data entry into a control.
- * Usually this is when the user removes focus from the component,
- * or when a property value is changed programmatically.
- * If you want a validator to ignore all events,
- * set <code>triggerEvent</code> to the empty string ("").
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get triggerEvent():String
- {
- return _triggerEvent;
- }
-
- /**
- * @private
- */
- public function set triggerEvent(value:String):void
- {
- if (_triggerEvent == value)
- return;
-
- removeTriggerHandler();
- _triggerEvent = value;
- addTriggerHandler();
- }
-
//--------------------------------------------------------------------------
//
// Properties: Errors
@@ -731,131 +282,12 @@ package org.apache.flex.utils.validation
public function set requiredFieldError(value:String):void
{
requiredFieldErrorOverride = value;
-
- _requiredFieldError = value != null ?
- value :
- resourceManager.getString(
- "validators", "requiredFieldError");
- }
-
-
//--------------------------------------------------------------------------
- //
- // Methods
- //
-
//--------------------------------------------------------------------------
-
- /**
- * This method is called when a Validator is constructed,
- * and again whenever the ResourceManager dispatches
- * a <code>"change"</code> Event to indicate
- * that the localized resources have changed in some way.
- *
- * <p>This event will be dispatched when you set the ResourceManager's
- * <code>localeChain</code> property, when a resource module
- * has finished loading, and when you call the ResourceManager's
- * <code>update()</code> method.</p>
- *
- * <p>Subclasses should override this method and, after calling
- * <code>super.resourcesChanged()</code>, do whatever is appropriate
- * in response to having new resource values.</p>
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- protected function resourcesChanged():void
- {
- requiredFieldError = requiredFieldErrorOverride;
- }
-
- /**
- * @private
- */
- private function addTriggerHandler():void
- {
- if (actualTrigger)
- actualTrigger.addEventListener(_triggerEvent, triggerHandler);
- }
-
- /**
- * @private
- */
- private function removeTriggerHandler():void
- {
- if (actualTrigger)
- actualTrigger.removeEventListener(_triggerEvent,
triggerHandler);
+ isRealValue(value)
+ if(isRealValue(value))
+ _requiredFieldError = value;
}
/**
- * Sets up all of the listeners for the
- * <code>valid</code> and <code>invalid</code>
- * events dispatched from the validator. Subclasses of the Validator
class
- * should first call the <code>removeListenerHandler()</code> method,
- * and then the <code>addListenerHandler()</code> method if
- * the value of one of their listeners or sources changes.
- * The CreditCardValidator and DateValidator classes use this
function internally.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- protected function addListenerHandler():void
- {
- var actualListener:Object;
- var listeners:Array = actualListeners;
-
- var n:int = listeners.length;
- for (var i:int = 0; i < n; i++)
- {
- actualListener = listeners[i];
- if (actualListener is IValidatorListener)
- {
- addEventListener(ValidationResultEvent.VALID,
-
IValidatorListener(actualListener).validationResultHandler);
-
- addEventListener(ValidationResultEvent.INVALID,
-
IValidatorListener(actualListener).validationResultHandler);
- }
- }
- }
-
- /**
- * Disconnects all of the listeners for the
- * <code>valid</code> and <code>invalid</code>
- * events dispatched from the validator. Subclasses should first call
the
- * <code>removeListenerHandler()</code> method and then the
- * <code>addListenerHandler</code> method if
- * the value of one of their listeners or sources changes.
- * The CreditCardValidator and DateValidator classes use this
function internally.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- protected function removeListenerHandler():void
- {
- var actualListener:Object;
- var listeners:Array = actualListeners;
-
- var n:int = listeners.length;
- for (var i:int = 0; i < n; i++)
- {
- actualListener = listeners[i];
- if (actualListener is IValidatorListener)
- {
- removeEventListener(ValidationResultEvent.VALID,
-
IValidatorListener(actualListener).validationResultHandler);
-
- removeEventListener(ValidationResultEvent.INVALID,
-
IValidatorListener(actualListener).validationResultHandler);
- }
- }
- }
-
- /**
* Returns <code>true</code> if <code>value</code> is not null.
*
* @param value The value to test.
@@ -909,10 +341,7 @@ package org.apache.flex.utils.validation
value:Object = null,
suppressEvents:Boolean =
false):ValidationResultEvent
{
- if (value == null)
- value = getValueFromSource();
-
- if (isRealValue(value) || required)
+ if (isRealValue(value))
{
// Validate if the target is required or our value is non-null.
return processValidation(value, suppressEvents);
@@ -923,7 +352,7 @@ package org.apache.flex.utils.validation
// validation was successful.
var resultEvent:ValidationResultEvent =
new ValidationResultEvent(ValidationResultEvent.VALID);
- if (!suppressEvents && _enabled)
+ if (!suppressEvents && enabled)
{
dispatchEvent(resultEvent);
}
@@ -931,45 +360,6 @@ package org.apache.flex.utils.validation
}
}
- /**
- * Returns the Object to validate. Subclasses, such as the
- * CreditCardValidator and DateValidator classes,
- * override this method because they need
- * to access the values from multiple subfields.
- *
- * @return The Object to validate.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- protected function getValueFromSource():Object
- {
- var message:String;
-
- if (_source && _property)
- {
- return _source[_property];
- }
-
- else if (!_source && _property)
- {
- message = resourceManager.getString(
- "validators", "SAttributeMissing");
- throw new Error(message);
- }
-
- else if (_source && !_property)
- {
- message = resourceManager.getString(
- "validators", "PAttributeMissing");
- throw new Error(message);
- }
-
- return null;
- }
-
/**
* @private
* Main internally used function to handle validation process.
@@ -980,7 +370,7 @@ package org.apache.flex.utils.validation
{
var resultEvent:ValidationResultEvent;
- if (_enabled)
+ if (enabled)
{
var errorResults:Array = doValidation(value);
@@ -1059,6 +449,38 @@ package org.apache.flex.utils.validation
return null;
}
+ [Inspectable(category="General", defaultValue="true")]
+
+ /**
+ * If <code>true</code>, specifies that a missing or empty
+ * value causes a validation error.
+ *
+ * @default true
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public var required:Boolean = true;
+
+ [Inspectable(category="General", defaultValue="true")]
+
+ /**
+ * Setting this value to <code>false</code> will stop the validator
+ * from performing validation.
+ * When a validator is disabled, it dispatch no events,
+ * and the <code>validate()</code> method returns null.
+ *
+ * @default true
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public var enabled:Boolean = true;
+
/**
* Returns a ValidationResultEvent from the Array of error results.
* Internally, this function takes the results from the
@@ -1125,28 +547,6 @@ package org.apache.flex.utils.validation
return resultEvent;
}
-
-
//--------------------------------------------------------------------------
- //
- // Event handlers
- //
-
//--------------------------------------------------------------------------
-
- /**
- * @private
- */
- private function triggerHandler(event:Event):void
- {
- validate();
- }
-
- /**
- * @private
- */
- private function resourceManager_changeHandler(event:Event):void
- {
- resourcesChanged();
- }
private var document:Object;
diff --git
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/ZipCodeValidator.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/ZipCodeValidator.as
index 64f9ac9..c55536f 100644
---
a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/ZipCodeValidator.as
+++
b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/validation/ZipCodeValidator.as
@@ -449,9 +449,7 @@ package org.apache.flex.utils.validation
if (DECIMAL_DIGITS.indexOf(c) != -1 ||
ROMAN_LETTERS.indexOf(c) != -1)
{
- var message:String = resourceManager.getString(
- "validators", "invalidFormatCharsZCV");
- throw new Error(message);
+ throw new Error(invalidFormatCharsZCV);
}
}
}
@@ -461,6 +459,7 @@ package org.apache.flex.utils.validation
_allowedFormatChars = value != null ?
value : " -";
}
+ public var invalidFormatCharsZCV:String;
//----------------------------------
// domain
@@ -739,22 +738,6 @@ package org.apache.flex.utils.validation
//
//--------------------------------------------------------------------------
- /**
- * @private
- */
- override protected function resourcesChanged():void
- {
- super.resourcesChanged();
-
- allowedFormatChars = allowedFormatCharsOverride;
- domain = domainOverride;
-
- invalidDomainError = invalidDomainErrorOverride;
- invalidCharError = invalidCharErrorOverride;
- wrongCAFormatError = wrongCAFormatErrorOverride;
- wrongLengthError = wrongLengthErrorOverride;
- wrongUSFormatError = wrongUSFormatErrorOverride;
- }
/**
* Override of the base class <code>doValidation()</code> method
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].