View Source EctoSparkles.Changesets (bonfire_umbrella v0.9.0-classic-beta.15)

Helper functions for changesets

Link to this section Summary

Functions

If a changeset includes a change to bool_field, we ensure that the timestamp field is updated if required. In the case of true, this means setting it to now if it is null and in the case of false, this means setting it to null if it is not null.

If a changeset includes a change to bool_field, we change two timestamps columns (representing activated and deactivated) so that only one is set to a non-null value at a time.

Validates that a URL uses HTTP(S) and has a correct format.

Link to this section Functions

Link to this function

change_synced_timestamp(changeset, bool_field, timestamp_field)

View Source
@spec change_synced_timestamp(Ecto.Changeset.t(), atom(), atom()) ::
  Ecto.Changeset.t()

If a changeset includes a change to bool_field, we ensure that the timestamp field is updated if required. In the case of true, this means setting it to now if it is null and in the case of false, this means setting it to null if it is not null.

Link to this function

change_synced_timestamps(changeset, bool_field, on_field, off_field, default \\ true)

View Source
@spec change_synced_timestamps(Ecto.Changeset.t(), atom(), atom(), atom(), atom()) ::
  Ecto.Changeset.t()

If a changeset includes a change to bool_field, we change two timestamps columns (representing activated and deactivated) so that only one is set to a non-null value at a time.

Link to this function

validate_exactly_one(changeset, columns, message)

View Source
Link to this function

validate_http_url(changeset, field)

View Source
@spec validate_http_url(Ecto.Changeset.t(), atom()) :: Ecto.Changeset.t()

Validates that a URL uses HTTP(S) and has a correct format.

Link to this function

validate_not_expired(cs, now \\ DateTime.utc_now(), column \\ :expires_at, message \\ "expired")

View Source
@spec validate_not_expired(Ecto.Changeset.t(), DateTime.t(), atom(), binary()) ::
  Ecto.Changeset.t()

Validates that the entity has not expired