wizard-field-composer.js.es6 662 B

12345678910111213141516171819202122232425262728
  1. import { observes } from 'ember-addons/ember-computed-decorators';
  2. export default Ember.Component.extend({
  3. classNames: 'wizard-field-composer',
  4. keyPress(e) {
  5. e.stopPropagation();
  6. },
  7. @observes('field.value')
  8. validate() {
  9. const minLength = Wizard.SiteSettings.min_post_length;
  10. const post = this.get('field.value');
  11. const field = this.get('field');
  12. field.set('customValidation', true);
  13. if (!post) {
  14. return field.setValid(false);
  15. }
  16. if (minLength && post.length < minLength) {
  17. return field.setValid(false, I18n.t('wizard.validation.too_short', { min: minLength }));
  18. }
  19. field.setValid(true);
  20. }
  21. });