abstract class FormObject::Base(T)

Overview

Base class for Jennifer form object.

This class works only with Jennifer ORM.

class ContactForm < FormObject::Base(Contact)
  attr :name, String
  attr :sex, String, origin: :gender
  attr :count, Int32, virtual: true
  attr :_deleted, Bool?, virtual: true
end

FormObject::Base supports Jennifer validation DSL and API.

class ContactForm < FormObject::Base(Contact)
  # ...
  attr :count, Int32, virtual: true

  validates_numericality :count, greater_than: 2
end

c = Contact.new
f = ContactForm.new(c)
f.verify(request)
f.valid?
f.errors # Jennifer::Model::Errors

Included Modules

Defined in:

form_object/base.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class FormObject::AbstractForm

assign_fields(context) assign_fields, persist persist, save save, skip skip, valid? valid?, verify(request : HTTP::Request) verify

Constructor methods inherited from class FormObject::AbstractForm

new new

Class methods inherited from class FormObject::AbstractForm

coercer coercer, go_deep_json(pull, context, depth = -1) go_deep_json, parse(request) parse, parse_json_array(pull, context_collection) parse_json_array, parse_json_object(pull, context) parse_json_object, read_json_form(request, context) read_json_form, read_multipart_form(request, context) read_multipart_form, read_query_params(request, context) read_query_params, read_url_encoded_form(request, context) read_url_encoded_form

Constructor Detail

def self.new(resource) #

[View source]

Class Method Detail

def self.all #

[View source]
def self.human_attribute_name(attr) #

[View source]

Instance Method Detail

def changed? #

[View source]
def errors #

[View source]
def new_record? #

[View source]
def persist #

[View source]
def persist_nested #

[View source]
def resource : T #

[View source]