FatEcto v0.5.0 FatUtils.Changeset View Source

Provides different changeset methods.

Link to this section Summary

Functions

Add custom error to changeset. If custom message is not provided default one will be used.

Add custom error message with field and error message.

If specific key is present in the changeset then other key passed as required will be set as required in the changeset.

Takes changeset and check if one of the key is present and return changeset error.

Takes changeset and check if none of or keys are present and return changeset error.

Compare datetime fields and return error if start date is before end date and it can also compare time by passing compare_type: :time in options.

Compare datetime fields and return error if start date is before or equal end date and it can also compare time by passing compare_type: :time in options.

Takes changeset and check if xor keys are present and return changeset error and also checks if xor keys are empty in the record and return error.

Link to this section Functions

Link to this function

add_error(changeset, error_message_title, error_message \\ "is invalid")

View Source

Add custom error to changeset. If custom message is not provided default one will be used.

Link to this function

error_msg_title(options, field_key, default_error_msg)

View Source

Add custom error message with field and error message.

Link to this function

require_if_change_present(changeset, list)

View Source

If specific key is present in the changeset then other key passed as required will be set as required in the changeset.

Link to this function

require_only_one_of(changeset, record, single_keys, options \\ [])

View Source

Takes changeset and check if one of the key is present and return changeset error.

Link to this function

require_or(changeset, record, or_keys, options \\ [])

View Source

Takes changeset and check if none of or keys are present and return changeset error.

Link to this function

validate_before(changeset, start_date_key, end_date_key, options \\ [])

View Source

Compare datetime fields and return error if start date is before end date and it can also compare time by passing compare_type: :time in options.

Link to this function

validate_before_equal(changeset, start_date_key, end_date_key, options \\ [])

View Source

Compare datetime fields and return error if start date is before or equal end date and it can also compare time by passing compare_type: :time in options.

Link to this function

validate_xor(changeset, record, xor_keys, options \\ [])

View Source

Takes changeset and check if xor keys are present and return changeset error and also checks if xor keys are empty in the record and return error.