ccdb-web/app/components/validated-field.js

18 lines
502 B
JavaScript

import Ember from 'ember';
const { Component, computed, get, isEmpty } = Ember;
export default Component.extend({
classNames: ['form-group'],
classNameBindings: ['isValid::has-error'],
isValid: computed('changeset.error', 'property', function() {
const changeset = this.get('changeset');
const property = this.get('property');
return isEmpty(get(changeset, `error.${property}`));
}),
hasLabel: computed('label', function() {
return !isEmpty(get(this, 'label'));
}),
});