Giter Club home page Giter Club logo

exonerate's Introduction

Exonerate

A JSONSchema -> Elixir compiler

example workflow

Erlang 26.0 warning

There is a bug in the Erlang compiler that causes Exonerate to fail on OTP version 26.0. Please use 26.1 or an earlier version or OTP.

Documentation

Documentation is available at: https://hexdocs.pm/exonerate

Performance

Accuracy benchmark relative to GPT-3.5 and GPT-4

Performance (speed) benchmark relative to other elixir JSONSchema libraries

JsonSchema support scope:

Currently supports JSONSchema drafts 4, 6, 7, 2019, 2020. except:

  • multipleOf is not supported for number types. This is because elixir does not support a floating point remainder guard, and also because it is impossible for a floating point to guarantee sane results (e.g. for IEEE Float64, 1.2 / 0.1 != 12)

  • id fields with fragments in their uri identifier

  • dynamicRefs and anchors.

  • contentMediaType, contentEncoding:

    Because Exonerate doesn't return the validated structured data, validating based on these filters will likely require a costly decode/parse step whose results will be immediately thrown away.

  • dictionaries

Note:

  • by default, ALL strings are considered to be invalid unless they are valid UTF-8 encodings and will be validated. If you require a raw binary, for example if you are ingesting raw data in multipart/form-encoded, use the {"format": "binary"} filter on your string.

Installation

Add the following lines to your mix.exs

  defp deps do
    [
      {:exonerate, "~> 1.1.0", runtime: false},
    ]
  end

Quick Start

defmodule SchemaModule do
  require Exonerate

  Exonerate.function_from_string(:def, :validate_input, """
  {
    "type":"object",
    "properties":{
      "parameter":{"type":"integer"}
    }
  }
  """)
end
iex> SchemaModule.validate_input("some string")
{:error, error_value: "some string", instance_location: "/", absolute_keyword_location: "#/type"}

iex> SchemaModule.validate_input(%{"parameter" => "2"})
{:error, error_value: "2", instance_location: "/parameter", absolute_keyword_location: "#/properties/parameter/type"}

iex> SchemaModule.validate_input(%{"parameter" => 2})
:ok

Licensing notes

This software contains verbatim code from https://github.com/json-schema-org/JSON-Schema-Test-Suite which is copyright Julian Berman, et. al, and released under the MIT license.

exonerate's People

Contributors

isaac-rstor avatar ityonemo avatar paulswartz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

exonerate's Issues

remove dependency on :idna

this erlang library is "relatively slow" and we don't need its full-featured decoding to properly do what we need for idna-hostnames.

Fix these warnings.

warning: variable "m" is unused (if the variable is not meant to be used, prefix it with an underscore)
lib/exonerate.ex:63: Exonerate.mismatch/3

warning: unused import Logger
lib/exonerate/method.ex:5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.