Class: NForm::Form

Inherits:
Object
  • Object
show all
Extended by:
Attributes
Includes:
Validations
Defined in:
lib/nform/form.rb

Instance Method Summary collapse

Methods included from Attributes

__hash_rep, __undef_attr, attribute, attribute_set, define_attributes, extended, get_coercion, hash_representation, undefined_attributes

Methods included from Validations

#errors, #validate_confirmation_of, #validate_length_of, #validate_numericality_of, #validate_presence_of

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
# File 'lib/nform/form.rb', line 8

def valid?
  errors.clear
  validate!
  true
rescue ValidationError
  false
end

#validate!Object



16
17
18
19
# File 'lib/nform/form.rb', line 16

def validate!
  yield if block_given?
  validation_error! if errors.any?
end