Module: Auth0::Mixins::Validation
- Included in:
- Api::V2::Actions, Api::V2::Guardian, Api::V2::Organizations, Api::V2::Roles, Api::V2::Users
- Defined in:
- lib/auth0/mixins/validation.rb
Overview
Module to provide validation for specific data structures.
Defined Under Namespace
Modules: Algorithm Classes: IdTokenValidator, JWTAlgorithm
Instance Method Summary collapse
-
#validate_permissions_array(permissions) ⇒ Object
Check a permissions array.
-
#validate_strings_array(strings) ⇒ Object
Check a roles array.
Instance Method Details
#validate_permissions_array(permissions) ⇒ Object
Check a permissions array
22 23 24 25 26 27 28 29 |
# File 'lib/auth0/mixins/validation.rb', line 22 def () raise Auth0::InvalidParameter, 'Must supply an array of Permissions' unless .kind_of?(Array) raise Auth0::MissingParameter, 'Must supply an array of Permissions' if .empty? raise Auth0::InvalidParameter, 'All array elements must be Permissions' unless .all? do || .kind_of? ::Auth0::Permission end .map { || .to_h } end |
#validate_strings_array(strings) ⇒ Object
Check a roles array
15 16 17 18 19 |
# File 'lib/auth0/mixins/validation.rb', line 15 def validate_strings_array(strings) raise Auth0::InvalidParameter, 'Must supply an array of strings' unless strings.kind_of?(Array) raise Auth0::MissingParameter, 'Must supply an array of strings' if strings.empty? raise Auth0::InvalidParameter, 'All array elements must be strings' unless strings.all? {|str| str.is_a? String} end |