- {{ input type="password" value=username id="confirmPassword" class="form-control"
+ {{ input type="password" value=confirmPassword id="confirmPassword" class="form-control"
name="confirmPassword" aria-describedby="confirmPasswordHelpBlock" }}
diff --git a/openchat/app/utils/text-input.js b/openchat/app/utils/text-input.js
new file mode 100644
index 0000000..bc1539a
--- /dev/null
+++ b/openchat/app/utils/text-input.js
@@ -0,0 +1,40 @@
+import Ember from 'ember';
+
+export const TextInput = Ember.Object.extend({
+ init() {
+ this._super(...arguments);
+ this.set('errors', {});
+ },
+
+ validate() {
+ let validators = this.get('validators');
+ let errors = {};
+ let value = this.get('value');
+ let hasErrors = false;
+
+ for (let i = 0; i < validators.length; i++) {
+ let validator = validators[i];
+
+ if (!validator.isValid(value)) {
+ errors[validator.validatorName] = validator;
+ hasErrors = true;
+ }
+ }
+
+ if (!hasErrors) {
+ errors = false;
+ }
+
+ this.set('errors', errors);
+ console.log(errors);
+ }
+});
+
+export function MaxLength(maxLength) {
+ this.validatorName = 'maxLength';
+ this.maxLength = maxLength;
+
+ this.isValid = function(value) {
+ return value.length <= this.maxLength;
+ };
+}