WeaviateEx.Validation.Property (WeaviateEx v0.7.4)
View SourceProperty value validation against schema data types.
Validates that property values conform to their declared data types before sending to Weaviate, providing early error detection.
Supported Data Types
text- String valuesint- Integer valuesnumber- Numeric values (integer or float)boolean- Boolean valuesdate- ISO8601 date/datetime strings or DateTime/Date structsuuid- UUID stringsblob- Base64-encoded binary datageoCoordinates- Geographic coordinatesphoneNumber- Phone number objectsobject- Nested object (map)- Arrays - Append
[]to any type (e.g.,text[],int[])
Examples
# Validate a single value
:ok = Property.validate("hello", "text")
{:error, msg} = Property.validate(123, "text")
# Validate an entire object against a schema
schema = %{"properties" => [
%{"name" => "title", "dataType" => ["text"]},
%{"name" => "count", "dataType" => ["int"]}
]}
object = %{"properties" => %{"title" => "Hello", "count" => 42}}
:ok = Property.validate_object(object, schema)
Summary
Functions
Validates a property value against its declared data type.
Validates all properties in an object against a schema.
Types
@type validation_result() :: :ok | {:error, String.t()}
Functions
@spec validate(term(), atom() | String.t()) :: validation_result()
Validates a property value against its declared data type.
Examples
Property.validate("hello", "text")
# => :ok
Property.validate(123, "text")
# => {:error, "Expected string for text type, got 123"}
Property.validate([1, 2, 3], "int[]")
# => :ok
Validates all properties in an object against a schema.
Examples
schema = %{"properties" => [
%{"name" => "title", "dataType" => ["text"]},
%{"name" => "count", "dataType" => ["int"]}
]}
object = %{"properties" => %{"title" => "Hello", "count" => 42}}
Property.validate_object(object, schema)
# => :ok
object = %{"properties" => %{"title" => 123, "count" => "not an int"}}
Property.validate_object(object, schema)
# => {:error, ["title: Expected string for text type, got 123", "count: Expected integer..."]}