module

Ralph::Schema::Validator

Validates model schemas against database schema

Constants

PG_TYPE_TO_CRYSTAL = {"smallint" => ["Int16", "Int32"], "integer" => ["Int32"], "bigint" => ["Int64"], "int2" => ["Int16", "Int32"], "int4" => ["Int32"], "int8" => ["Int64"], "serial" => ["Int32"], "bigserial" => ["Int64"], "smallserial" => ["Int16", "Int32"], "real" => ["Float32"], "float4" => ["Float32"], "double precision" => ["Float64"], "float8" => ["Float64"], "numeric" => ["Float64", "PG::Numeric", "BigDecimal"], "decimal" => ["Float64", "PG::Numeric", "BigDecimal"], "text" => ["String"], "varchar" => ["String"], "character varying" => ["String"], "char" => ["String"], "character" => ["String"], "name" => ["String"], "boolean" => ["Bool"], "bool" => ["Bool"], "timestamp" => ["Time"], "timestamp without time zone" => ["Time"], "timestamp with time zone" => ["Time"], "timestamptz" => ["Time"], "date" => ["Time"], "time" => ["Time"], "time without time zone" => ["Time"], "time with time zone" => ["Time"], "timetz" => ["Time"], "uuid" => ["UUID"], "json" => ["JSON::Any"], "jsonb" => ["JSON::Any"], "bytea" => ["Bytes", "Slice(UInt8)"], "text[]" => ["Array(String)"], "integer[]" => ["Array(Int32)"], "bigint[]" => ["Array(Int64)"], "boolean[]" => ["Array(Bool)"]}

PostgreSQL type mappings to Crystal types Used to check if model types match database types

Class methods

report

Print a validation report for all models

Source
validate(model_class : Ralph::Model.class) : ValidationResult

Validate a model class against the database schema

Source
validate!(model_class : Ralph::Model.class) : Nil

Validate a model and raise if invalid

Source
validate_all

Validate all registered model classes

Source
validate_all!

Validate all models and raise if any are invalid

Source