View Source Ravix.Documents.Session.Validations (ravix v0.2.2)

Validation rules for session states

Link to this section Summary

Functions

Returns an error if all the informed ids are already loaded in the session

Return an error if the document is not in the session

Returns an error if the document is already marked for deletion

Returns an error if the document is in a deferred command

Returns an error if the document is already stored in the session

Link to this section Functions

Link to this function

all_ids_are_not_already_loaded(document_ids, already_loaded_ids)

View Source
@spec all_ids_are_not_already_loaded(list(), list()) ::
  {:error, :all_ids_already_loaded} | {:ok, [...]}

Returns an error if all the informed ids are already loaded in the session

Link to this function

document_in_session?(state, entity_id)

View Source
@spec document_in_session?(Ravix.Documents.Session.State.t(), any()) ::
  {:error, :document_not_in_session} | {:ok, map()}

Return an error if the document is not in the session

Link to this function

document_not_deleted(state, entity_id)

View Source
@spec document_not_deleted(Ravix.Documents.Session.State.t(), binary()) ::
  {:ok, binary()} | {:error, :document_deleted}

Returns an error if the document is already marked for deletion

Link to this function

document_not_in_deferred_command(state, entity_id)

View Source
@spec document_not_in_deferred_command(Ravix.Documents.Session.State.t(), binary()) ::
  {:ok, binary()} | {:error, :document_already_deferred}

Returns an error if the document is in a deferred command

Link to this function

document_not_stored(state, entity_id)

View Source
@spec document_not_stored(Ravix.Documents.Session.State.t(), binary()) ::
  {:error, {:document_already_stored, map()}} | {:ok, map()}

Returns an error if the document is already stored in the session

Link to this function

load_documents_limit_reached(state, document_ids)

View Source
@spec load_documents_limit_reached(Ravix.Documents.Session.State.t(), list()) ::
  {:error, :max_amount_of_ids_reached} | {:ok, -1}
Link to this function

session_request_limit_reached(state)

View Source
@spec session_request_limit_reached(Ravix.Documents.Session.State.t()) ::
  {:error, :max_amount_of_requests_reached} | {:ok, -1}