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.
Validates that the entity has not expired
Link to this section Functions
@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.
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.
@spec validate_http_url(Ecto.Changeset.t(), atom()) :: Ecto.Changeset.t()
Validates that a URL uses HTTP(S) and has a correct format.
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