-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Loïc Knuchel
committed
Jan 7, 2024
1 parent
569e272
commit de94b73
Showing
4 changed files
with
113 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule AzimuttWeb.Utils.JsonSchema do | ||
@moduledoc "JSON Schema helpers" | ||
alias Azimutt.Utils.Result | ||
|
||
def validate(json, schema) do | ||
# TODO: add the string uuid format validation | ||
ExJsonSchema.Validator.validate(schema, json) | ||
|> Result.map_both( | ||
fn errors -> %{errors: errors |> Enum.map(fn {error, path} -> %{path: path, error: error} end)} end, | ||
fn _ -> json end | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters