/**
 * Generated by Apache Royale Compiler from org\apache\royale\jewel\beads\validators\DateValidator.as
 * org.apache.royale.jewel.beads.validators.DateValidator
 *
 * @fileoverview
 *
 * @suppress {checkTypes|accessControls}
 */

goog.provide('org.apache.royale.jewel.beads.validators.DateValidator');

goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.jewel.DateField');
goog.require('org.apache.royale.jewel.beads.validators.Validator');
goog.require('org.apache.royale.utils.Language');



/**
 *  constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 * @constructor
 * @extends {org.apache.royale.jewel.beads.validators.Validator}
 */
org.apache.royale.jewel.beads.validators.DateValidator = function() {
  org.apache.royale.jewel.beads.validators.DateValidator.base(this, 'constructor');
};
goog.inherits(org.apache.royale.jewel.beads.validators.DateValidator, org.apache.royale.jewel.beads.validators.Validator);


/**
 * Prevent renaming of class. Needed for reflection.
 */
goog.exportSymbol('org.apache.royale.jewel.beads.validators.DateValidator', org.apache.royale.jewel.beads.validators.DateValidator);


/**
 * @private
 * @param {*} d
 * @return {boolean}
 */
org.apache.royale.jewel.beads.validators.DateValidator.prototype.org_apache_royale_jewel_beads_validators_DateValidator_isValidDate = function(d) {
  return org.apache.royale.utils.Language.is(d, Date) && !isNaN(d);
};


/**
 *  Override of the base class validate() method to validate if selected.
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 * @export
 * @override
 */
org.apache.royale.jewel.beads.validators.DateValidator.prototype.validate = function(event) {
  event = typeof event !== 'undefined' ? event : null;
  var /** @type {org.apache.royale.jewel.DateField} */ df = org.apache.royale.utils.Language.as(this.hostComponent, org.apache.royale.jewel.DateField);
  if (org.apache.royale.jewel.beads.validators.DateValidator.superClass_.validate.apply(this, [ event] )) {
    if (!this.org_apache_royale_jewel_beads_validators_DateValidator_isValidDate(df.selectedDate)) {
      this.createErrorTip(this.requiredFieldError);
    } else {
      this.destroyErrorTip();
    }
  }
  return !this.isError;
};


org.apache.royale.jewel.beads.validators.DateValidator.prototype.set__strand = function(value) {
  org.apache.royale.jewel.beads.validators.DateValidator.superClass_.set__strand.apply(this, [ value] );
  this.hostComponent.addEventListener(org.apache.royale.events.Event.CHANGE, org.apache.royale.utils.Language.closure(this.validate, this, 'validate'), false);
};


Object.defineProperties(org.apache.royale.jewel.beads.validators.DateValidator.prototype, /** @lends {org.apache.royale.jewel.beads.validators.DateValidator.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.jewel.beads.validators.DateValidator.prototype.set__strand}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.royale.jewel.beads.validators.DateValidator.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'DateValidator', qName: 'org.apache.royale.jewel.beads.validators.DateValidator', kind: 'class' }] };



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.jewel.beads.validators.DateValidator.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.jewel.beads.validators.DateValidator'}
      };
    },
    methods: function () {
      return {
        'DateValidator': { type: '', declaredBy: 'org.apache.royale.jewel.beads.validators.DateValidator'},
        'validate': { type: 'Boolean', declaredBy: 'org.apache.royale.jewel.beads.validators.DateValidator', parameters: function () { return [  { index: 1, type: 'org.apache.royale.events.Event', optional: true } ]; }}
      };
    }
  };
};