Skip to content

Instantly share code, notes, and snippets.

@ivan-hilckov
Created July 26, 2012 12:45
Show Gist options
  • Select an option

  • Save ivan-hilckov/3181831 to your computer and use it in GitHub Desktop.

Select an option

Save ivan-hilckov/3181831 to your computer and use it in GitHub Desktop.
model_openid_test.coffee
class Elections.Model.Openid extends Elections.Model.Base
url: "/auth/open_id"
validation:
openid_url: [{
required: true
pattern: /^(https?:\/\/)?([\w\.]+)\.([a-z]{2,6}\.?)(\/[\w\.]*)*\/?$/
msg: "Введите OpenID"
}]
save: ->
xhr = super
xhr.always =>
@errorСatcher( xhr )
return xhr
errorСatcher: ( xhr ) ->
switch xhr.status
when 422
if JSON.parse( xhr.responseText ).error_type is "connection_failed"
@.trigger "invalid", "openid_url", "Неверный OpenID"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment