All Projects → phink → changeset

phink / changeset

Licence: MIT License
(unreleased) Data validation with first-class and first-order labels in OCaml

Programming Languages

ocaml
1615 projects
Makefile
30231 projects

Projects that are alternatives of or similar to changeset

Pywhip
💂‍♂️ Python package to validate data against whip specifications
Stars: ✭ 5 (-82.14%)
Mutual labels:  data-validation
Data Cleaning 101
Data Cleaning Libraries with Python
Stars: ✭ 243 (+767.86%)
Mutual labels:  data-validation
check-engine
Data validation library for PySpark 3.0.0
Stars: ✭ 29 (+3.57%)
Mutual labels:  data-validation
Saul
Data validation and conformation library for Elixir.
Stars: ✭ 62 (+121.43%)
Mutual labels:  data-validation
Rdfunit
An RDF Unit Testing Suite
Stars: ✭ 117 (+317.86%)
Mutual labels:  data-validation
minimallist
A minimalist data driven data model library, inspired by Clojure Spec and Malli.
Stars: ✭ 63 (+125%)
Mutual labels:  data-validation
Pointblank
Data validation and organization of metadata for data frames and database tables
Stars: ✭ 480 (+1614.29%)
Mutual labels:  data-validation
form-binder-java
Java port of form-binder, a micro data binding and validating framework
Stars: ✭ 29 (+3.57%)
Mutual labels:  data-validation
Cerberus
Lightweight, extensible data validation library for Python
Stars: ✭ 2,640 (+9328.57%)
Mutual labels:  data-validation
IATI.cloud
The open-source IATI datastore for IATI data with RESTful web API providing XML, JSON, CSV output. It extracts and parses IATI XML files referenced in the IATI Registry and powered by Apache Solr.
Stars: ✭ 35 (+25%)
Mutual labels:  data-validation
Passable
Declarative data validations.
Stars: ✭ 93 (+232.14%)
Mutual labels:  data-validation
Typical
Typical: Fast, simple, & correct data-validation using Python 3 typing.
Stars: ✭ 111 (+296.43%)
Mutual labels:  data-validation
objectiv-analytics
Powerful product analytics for data teams, with full control over data & models.
Stars: ✭ 399 (+1325%)
Mutual labels:  data-validation
Dry Validation
Validation library with type-safe schemas and rules
Stars: ✭ 1,087 (+3782.14%)
Mutual labels:  data-validation
deepchecks
Test Suites for Validating ML Models & Data. Deepchecks is a Python package for comprehensively validating your machine learning models and data with minimal effort.
Stars: ✭ 1,595 (+5596.43%)
Mutual labels:  data-validation
Pandera
A light-weight, flexible, and expressive pandas data validation library
Stars: ✭ 506 (+1707.14%)
Mutual labels:  data-validation
Dry Schema
Coercion and validation for data structures
Stars: ✭ 249 (+789.29%)
Mutual labels:  data-validation
validation-components
A collection of common validation predicates for ValidationToolkit framework
Stars: ✭ 26 (-7.14%)
Mutual labels:  data-validation
pyvaru
Rule based data validation library for python 3.
Stars: ✭ 17 (-39.29%)
Mutual labels:  data-validation
form-binder
A micro data binding and validating framework, very easy to use and hack
Stars: ✭ 18 (-35.71%)
Mutual labels:  data-validation

This is WIP.

Service OCaml Service
Circle 4.06 Build Status

Changeset

Data validation with first-class and first-order labels in OCaml.

Homepage for the library is available here.

Changesets are tools to validate data while accumulating errors along the way. They are composed of:

  • Changes: an heterogeneous map whose keys are of type 'a label and values 'a. When deriving a changeset from a record type definition, the labels correspond to the fields of this one.

  • Errors: a list of strings associated with labels.

Labels are first-class, that means you can give them as argument to functions, and first-order, so you can pattern match against them. The library promotes the pipeline design approach.

There is a ppx deriving plugin so there is no need to write any boilerplate code.

Install using opam

$ opam pin add changeset_lib https://github.com/phink/changeset.git
$ opam pin add ppx_changeset https://github.com/phink/changeset.git

Update the libraries and preprocess section in your jbuild file:

(libraries (... changeset))
(preprocess (pps (... ppx_changeset)))

Minimal example

type t = {
  age: int;
  phone: string;
  password: string;
} [@@deriving changeset]

let validate cset =
  cset
  |> Changeset.validate_int Age [`greater_than_or_equal_to 0]
  |> Changeset.validate_string_length Password [`min 12]
  |> Changeset.validate_format Phone (Str.regexp "^\\+?[1-9][0-9]+$")

let create t =
  let cset = Changeset.from_record t in
  Changeset.apply (validate cset)

let data = {age = 12; password = "dolphin"; phone = "+14155552671"}

let () = match create data with
  | Ok t -> (* do what you want *)
  | Error cset ->
    Stdio.prerr_endline (Changeset.show_errors cset)

Execution

{
  "errors":{
    "password":"should be at least 12 character(s)"
  }
}

Limitations

Parameterized source types are not yet supported.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].