Skip to content

JSON Predicate implementation.

License

Notifications You must be signed in to change notification settings

satom99/ex_snell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ex_snell

A JSON Predicate implementation in accordance to the Snell RFC draft.

Usage

Let us consider the following predicate.

predicate = %{
  op: "and",
  path: "/b",
  apply: [
    %{
      op: "less",
      value: 3
    },
    %{
      op: "more",
      value: 5
    },
    %{
      op: "type",
      value: "integer"
    }
  ]
}

In order to validate this against a structure, a boolean function can be generated as follows.

fun = Snell.parse(predicate)

Once we have this, we can proceed to verify whether a struct suffices the given predicate.

struct = %{
  b: 4
}
fun.(struct)

Do notice though that type values are Elixir types, and thus not necessarily JavaScript types.

Mineteria

This library was developed for use under the Mineteria framework.
However, it was decided to be released onto the public domain. Thanks!
Mineteria

Releases

No releases published

Packages

No packages published

Languages