Integrate.SpecificationData (IntegrateDB v0.1.0) View Source
Validate and transform specification data.
Link to this section Summary
Functions
Reverses expand
, so the full form data is compacted into the tersest equivalent
syntax. Accepts and returns a map.
Expand "terse" syntactic sugar in the spec data into its equivalent full form.
Use a JSON Schema to validate user input specifications.
Validate and then expand user input specification data.
Link to this section Functions
Reverses expand
, so the full form data is compacted into the tersest equivalent
syntax. Accepts and returns a map.
Examples
iex> attrs = %Spec{
match: [
%Match{
alternatives: %MatchAlternative{
path: %Path{
schema: "public",
table: "users"
},
fields: [
%Field{
alternatives: [
%FieldAlternative{
name: "id"
}
]
},
%Field{
alternatives: [
%FieldAlternative{
name: "uuid"
}
]
]
}
}
}
]
}
iex> contract(attrs)
%{match: [%{path: "public.users", fields: ["id", "uuid"]}]}
Expand "terse" syntactic sugar in the spec data into its equivalent full form.
Accepts and returns a map.
Examples
iex> expand(%{"match": [%{path" => "public.users", "fields" => ["id", "uuid"]}]})
%{
"match" => [
%{
"alternatives" => [
"path" => %{
"schema" => "public",
"table" => "users"
},
"fields" => [
%{
"alternatives" => [
%{"name" => "id"}
]
},
%{
"alternatives" => [
%{"name": "uuid"}
]
}
}
]
}
]
}
Use a JSON Schema to validate user input specifications.
Returns :ok
or {:error, json_schema_errors}
.
Examples
iex> validate(%{})
:ok
iex> validate(%{"foo" => 1})
{:error, [{"Type mismatch. Expected String but got Integer.", "#/foo"}]}
Validate and then expand user input specification data.
Returns {:ok, attrs}
or {:error, json_schema_errors}
.