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



11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/marty/api_auth.rb', line 11

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") if
    Marty::Script.find_script(api.script_name, nil).nil?
end