Handle validation error messages better
This commit is contained in:
parent
0df22b4c3b
commit
ecd1b7292c
|
@ -2,12 +2,16 @@ get = Ember.get
|
||||||
|
|
||||||
Error = Ember.Object.extend
|
Error = Ember.Object.extend
|
||||||
message: (->
|
message: (->
|
||||||
switch @get('code')
|
switch code = @get('code')
|
||||||
when 'blank' then "can't be blank"
|
when 'blank' then "can't be blank"
|
||||||
when 'not_a_private_key' then "the key is not a valid private key"
|
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')
|
).property('code')
|
||||||
|
|
||||||
|
humanize: (str) ->
|
||||||
|
str.replace(/_id$/, '').replace(/_/g, ' ').replace(/^\w/g, (s) -> s.toUpperCase())
|
||||||
|
|
||||||
FieldErrors = Ember.ArrayProxy.extend
|
FieldErrors = Ember.ArrayProxy.extend
|
||||||
add: (error) ->
|
add: (error) ->
|
||||||
@get('content').pushObject(error)
|
@get('content').pushObject(error)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user