From ecd1b7292cba7faecd1408689011aeb4759cd14d Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 25 Aug 2014 13:15:54 +0200 Subject: [PATCH] Handle validation error messages better --- assets/scripts/lib/travis/validations.coffee | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/scripts/lib/travis/validations.coffee b/assets/scripts/lib/travis/validations.coffee index f39d375f..25ca1567 100644 --- a/assets/scripts/lib/travis/validations.coffee +++ b/assets/scripts/lib/travis/validations.coffee @@ -2,12 +2,16 @@ get = Ember.get Error = Ember.Object.extend message: (-> - switch @get('code') + switch code = @get('code') when 'blank' then "can't be blank" when 'not_a_private_key' then "the key is not a valid private key" - else "unknown error" + when 'key_with_a_passphrase' then 'we can\'t use key with a passphrase' + else @humanize(code) ).property('code') + humanize: (str) -> + str.replace(/_id$/, '').replace(/_/g, ' ').replace(/^\w/g, (s) -> s.toUpperCase()) + FieldErrors = Ember.ArrayProxy.extend add: (error) -> @get('content').pushObject(error)