class OptParseValidator::OptCredentials

Implementation of the Credentials Option

Public Instance Methods

validate(value) click to toggle source

@return [ Hash ] A hash containing the :username and :password

# File lib/opt_parse_validator/opts/credentials.rb, line 7
def validate(value)
  raise Error, 'Incorrect credentials format, username:password expected' unless value.index(':')

  creds = value.split(':', 2)

  { username: creds[0], password: creds[1] }
end