Hello!
I’m excited to announce the preview release of a new library called validate
! This library aims to make the process of validating records, lists, or individual values more streamlined and efficient.
validate
operates through a PPX deriver that automatically generates validators using annotations. It comes with an array of helper validation functions for different data types, making it versatile and easy to integrate into your projects.
Example Usage:
Imagine you have a record type with various fields that need validation. With validate
, you can easily annotate these fields and the library will handle the rest. For example:
type my_record = {
min : string; [@min_length 2]
email : string; [@email]
uuid : string; [@uuid]
url : string; [@url] [@max_length 200]
numeric_list : int list; [@list_min_length 2] [@less_than 10]
other_record: other; [@dive]
} [@@deriving validate]
This will automatically create a validate_my_record
function, applying the specified validations to each field.
Installation:
You can install validate
using OPAM:
Copy code
opam install validate
I encourage you to try it out, and your feedback and contributions are invaluable at this stage.
For more details, please visit GitHub repository and check out the documentation.