class Marten::Schema::Field::String
- Marten::Schema::Field::String
- Marten::Schema::Field::Base
- Reference
- Object
Overview
Represents a string schema field.
Direct Known Subclasses
Defined in:
marten/schema/field.crmarten/schema/field/string.cr
Constructors
Instance Method Summary
-
#deserialize(value) : ::String | Nil
Deserializes a raw field value to the corresponding field value.
-
#max_size : Int32?
Returns the maximum string size allowed.
-
#min_size : Int32?
Returns the minimum string size allowed.
-
#serialize(value) : ::String | Nil
Serializes a field value.
-
#strip? : Bool
Returns
true
if the string value should be stripped of leading and trailing whitespaces. -
#validate(schema, value)
Runs custom validation logic for a specific schema field and schema object.
Instance methods inherited from class Marten::Schema::Field::Base
deserialize(value)
deserialize,
empty_value?(value) : ::Bool
empty_value?,
id : String
id,
required? : Bool
required?,
serialize(value) : ::String | Nil
serialize,
validate(schema, value)
validate
Constructor methods inherited from class Marten::Schema::Field::Base
new(id : ::String, required : ::Bool = true)
new
Macros inherited from module Marten::Template::Object
template_attributes(*names)
template_attributes
Constructor Detail
def self.new(id : ::String, required : ::Bool = true, max_size : Int32 | Nil = nil, min_size : Int32 | Nil = nil, strip : ::Bool = true)
#
Instance Method Detail
def deserialize(value) : ::String | Nil
#
Description copied from class Marten::Schema::Field::Base
Deserializes a raw field value to the corresponding field value.
def serialize(value) : ::String | Nil
#
Description copied from class Marten::Schema::Field::Base
Serializes a field value.
def strip? : Bool
#
Returns true
if the string value should be stripped of leading and trailing whitespaces.
def validate(schema, value)
#
Description copied from class Marten::Schema::Field::Base
Runs custom validation logic for a specific schema field and schema object.
This method should be overriden for each field implementation that requires custom validation logic.