<commit_before>// import Ember from 'ember';
import Validator from '../validator';

/* global moment */

export default Validator.extend({
  options: {
    dateFormat: 'YYYY-MM-DD',
    timeFormat: 'HH:mm:ss',
  },

  call: function(value) {
    this.clearErrors();

    if(this.isSet(value)) {
      var formats = [
        this.get('options.dateFormat'),
        this.get('options.dateFormat') + ' ' + this.get('options.timeFormat'),
      ];

      return moment(value, formats, true).isValid();
    }

    return true;
  }
});<commit_msg>Fix date validator not throwing an error message<commit_after>// import Ember from 'ember';
import Validator from '../validator';

/* global moment */

export default Validator.extend({
  options: {
    dateFormat: 'YYYY-MM-DD',
    timeFormat: 'HH:mm:ss',
  },

  errorMessages: {
    main: 'Invalid date format',
  },

  call: function(value) {
    this.clearErrors();

    if(this.isSet(value)) {
      var formats = [
        this.get('options.dateFormat'),
        this.get('options.dateFormat') + ' ' + this.get('options.timeFormat'),
      ];

      if(moment(value, formats, true).isValid()) {
        return true;
      } else {
        this.addError();
        return false;
      }
    }

    return true;
  }
});
{'fraction_non_alphanumeric': 0.16192733017377567, 'fraction_numerical': 0.0, 'mean_word_length': 2.62, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5909823', 'n_tokens_mistral': 403, 'n_tokens_neox': 397, 'n_words': 85}