ApiCommons.Utils (ApiCommons v0.1.0) View Source

Utils useable for parameter checks.

Link to this section Summary

Functions

Cast value of a paramter to a specific type. 
If value already of specified type, just return the value

## Parameter
    - value (any) The value to parse
    - type (atom) One of following values [:id, :integer, :float, ...]. Representing the type to parse to

## Returns
    - The casted value or an error code {error_type, code}

## Examples
Check wether field should be excluded for further processing.

## Parameter
    - field_name (atom) The field name to check against
    - atom_list (list(atom)|atom) A list of fields or a single value to exclude.

## Returns


## Examples
Check if the passed value is of the schema type.

## Parameter
    - field_value (any) Any value to check against
    - type (Ecto.Type) Field type primitives to check for

Link to this section Functions

Cast value of a paramter to a specific type. 
If value already of specified type, just return the value

## Parameter
    - value (any) The value to parse
    - type (atom) One of following values [:id, :integer, :float, ...]. Representing the type to parse to

## Returns
    - The casted value or an error code {error_type, code}

## Examples
Link to this function

includes?(atom_list, field_name)

View Source
Check wether field should be excluded for further processing.

## Parameter
    - field_name (atom) The field name to check against
    - atom_list (list(atom)|atom) A list of fields or a single value to exclude.

## Returns


## Examples
Link to this function

is_type(field_value, type)

View Source
Check if the passed value is of the schema type.

## Parameter
    - field_value (any) Any value to check against
    - type (Ecto.Type) Field type primitives to check for