Class: Marty::ApiAuth::ApiAuthValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/models/marty/api_auth.rb

Instance Method Summary collapse

Instance Method Details

#validate(api) ⇒ Object



9
10
11
12
13
14
15
# File 'app/models/marty/api_auth.rb', line 9

def validate(api)
  api.errors.add(:base, "API Key length must be #{KEY_SIZE*2}") if
    api.api_key && api.api_key.length != KEY_SIZE*2

  api.errors.add(:base, "Script Name must reference a valid script") unless
    Marty::Script.find_script(api.script_name, nil)
end