Skip to content

Custom Validation #2

@cddr

Description

@cddr

As a developer, I'd like to be able to add custom validation rules that are checked as part of the transaction so that I can be sure of the integrity of persisted data.

Functional Requirements

  • The definition given to defentity should support a new option :validation.
  • This should be a function that accepts two arguments. The first is a datomic database instance as-of the start of the transaction. The second is the input data that is to be applied relating to this entity. The function should return a two element tuple, the first of which indicates whether it is ok to proceed with the transaction, and the second indicates any error messages if it is not ok.
  • This function should be called during POST/PUT/PATCH operations to decide whether it is ok to process the request. If the transaction fails, the request handler should return with a 422 containing any error messages in the response body

Non-Functional Requirements

  • To avoid race conditions, this should probably be implemented as a database function through which all database writes are performed
  • There are a whole bunch of existing clojure libraries for validating user input. It would be nice if our implementation did not prevent them from using whatever one they want.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions