Scrutinex.Checks.Custom (Scrutinex v0.2.0)

Copy Markdown View Source

Runs a user-supplied function as a column-level check.

Summary

Functions

Calls func.(value) and returns :ok if truthy, otherwise a generic error.

Functions

run(value, func)

@spec run(term(), (term() -> boolean()) | {(term() -> boolean()), String.t()}) ::
  :ok | {:error, String.t(), map()}

Calls func.(value) and returns :ok if truthy, otherwise a generic error.

Accepts either a plain function or a {function, message} tuple. When a tuple is given, the custom message is used in the error instead of the default "custom check failed" text.

If the function raises, the exception is caught and returned as a validation error rather than crashing the pipeline.