hecate_plugin_validate (hecate_sdk v0.6.2)
View SourceInput validation helpers for plugin API handlers.
Validates maps (typically JSON request bodies) against rules. Returns {ok, Validated} with only declared fields, or {error, Errors} with a list of validation failures.
Example: Rules = [ {title, required, binary}, {body, required, binary}, {tags, optional, {list, binary}, []}, {priority, optional, {one_of, [low, medium, high]}, medium} ], case hecate_plugin_validate:check(Input, Rules) of {ok, #{title := T, body := B}} -> ...; {error, Errors} -> ... end.
Summary
Functions
Validate a map against a list of rules.
Require a key exists in a map. Returns value or error.
Require a binary value.
Require an integer value.
Types
Functions
Validate a map against a list of rules.
Require a key exists in a map. Returns value or error.
Require a binary value.
Require an integer value.