0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 04:12:53 +01:00
discourse-custom-wizard/assets/javascripts/wizard/components/wizard-field-composer.js.es6
Angus McLeod dd26ac63af various
2017-10-09 13:52:09 +08:00

28 Zeilen
662 B
JavaScript

import { observes } from 'ember-addons/ember-computed-decorators';
export default Ember.Component.extend({
classNames: 'wizard-field-composer',
keyPress(e) {
e.stopPropagation();
},
@observes('field.value')
validate() {
const minLength = Wizard.SiteSettings.min_post_length;
const post = this.get('field.value');
const field = this.get('field');
field.set('customValidation', true);
if (!post) {
return field.setValid(false);
}
if (minLength && post.length < minLength) {
return field.setValid(false, I18n.t('wizard.validation.too_short', { min: minLength }));
}
field.setValid(true);
}
});