Added model email validation.

This commit is contained in:
Martin Edenhofer 2015-08-28 10:46:09 +02:00
parent 7e8b3adc3b
commit 6904c89668
2 changed files with 8 additions and 1 deletions

View file

@ -138,6 +138,13 @@ class App.Model extends Spine.Model
errors[attributeName] = 'didn\'t match'
errors["#{attributeName}_confirm"] = ''
# check email
if attribute.type is 'email' && data['params'][attributeName]
if !data['params'][attributeName].match(/\S+@\S+\.\S+/)
errors[attributeName] = 'invalid'
if data['params'][attributeName].match(/ /)
errors[attributeName] = 'invalid'
# check datetime
if attribute.tag is 'datetime'
if data['params'][attributeName] is 'invalid'

View file

@ -14,7 +14,7 @@ class App.EmailAddress extends App.Model
@configure_attributes = [
{ name: 'realname', display: 'Realname', tag: 'input', type: 'text', limit: 250, null: false },
{ name: 'email', display: 'Email', tag: 'input', type: 'email', limit: 250, null: false },
{ name: 'channel_id', display: 'Channel', tag: 'select', multiple: false, null: false, relation: 'Channel', nulloption: true, filter: @filterChannel },
{ name: 'channel_id', display: 'Channel', tag: 'select', multiple: false, null: true, relation: 'Channel', nulloption: true, filter: @filterChannel },
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
{ name: 'active', display: 'Active', tag: 'active', default: true },