module
Amber::Schema::TypeCoercion
Defined in:
amber/schema/type_coercion.crConstant Summary
-
FALSE_VALUES =
{"false", "0", "no", "n", "off", "f", "disabled", "inactive"} -
TIME_FORMATS =
["%Y-%m-%dT%H:%M:%S.%LZ", "%Y-%m-%dT%H:%M:%S.%L%:z", "%Y-%m-%dT%H:%M:%S%:z", "%Y-%m-%dT%H:%M:%SZ", "%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M:%S %z", "%Y-%m-%d %H:%M:%S.%L", "%Y/%m/%d %H:%M:%S", "%Y-%m-%d", "%Y/%m/%d", "%m/%d/%Y %H:%M:%S", "%d/%m/%Y %H:%M:%S", "%m-%d-%Y", "%d-%m-%Y", "%m/%d/%Y", "%d/%m/%Y"] -
Common time formats for parsing
-
TRUE_VALUES =
{"true", "1", "yes", "y", "on", "t", "enabled", "active"} -
Common boolean string representations
Class Method Summary
-
.can_coerce?(value : JSON::Any, target_type : String) : Bool
Utility method to check if a value can be coerced to a type
-
.clear_custom_coercions
Clear all custom coercions
-
.coerce(value : JSON::Any, target_type : String) : JSON::Any | Nil
Main coercion method
-
.coercion_error(field : String, value : JSON::Any, target_type : String) : CoercionError
Get a descriptive error for a failed coercion
-
.register(type : String, &block : JSON::Any -> JSON::Any | Nil)
Register a custom coercion function for a type
Class Method Detail
Utility method to check if a value can be coerced to a type
Main coercion method
Get a descriptive error for a failed coercion
Register a custom coercion function for a type