default error message is in place

This commit is contained in:
Gant
2014-08-07 22:44:28 -05:00
parent d1b6e384b5
commit 4d8cbd2eee

View File

@@ -54,6 +54,20 @@ module RubyMotionQuery
return result
end
# @return [Array] of error messages for faild validations
def validation_errors
errors = []
selected.each do |view|
view.rmq_data.validations.each do |validation|
unless validation.valid_status
default_error = "Validation Error - input requires valid #{validation.rule_name.to_s}."
errors.push(default_error)
end
end
end
return errors
end
# @return [Array] of views where validations have failed
def invalid
invalid = []
@@ -79,13 +93,14 @@ module RubyMotionQuery
end # End RMQ
class Validation
attr_reader :valid_status
attr_reader :valid_status, :rule_name
def initialize(rule, options={})
@rule = @@validation_methods[rule]
raise "RMQ validation error: :#{rule} is not one of the supported validation methods." unless @rule
@rule_name = rule
@options = options
@valid_status = true
raise "RMQ validation error: :#{rule} is not one of the supported validation methods." unless @rule
end
def valid?(data, options={})