email validator tests, live coding later error message
This commit is contained in:
@ -33,7 +33,11 @@ class AnswerFormatValidator < ActiveModel::EachValidator
|
||||
def live_code record, attribute, value
|
||||
return unless value.nil? || value.values.join.blank?
|
||||
|
||||
msg = "You must write code in one of the above textareas to progress."
|
||||
msg = if value.present? && value.keys.count == 1
|
||||
"Please check that you will come back to complete the code example."
|
||||
else
|
||||
"You must write code in one of the above textareas to progress."
|
||||
end
|
||||
record.errors[attribute] << (options[:message] || msg)
|
||||
end
|
||||
end
|
||||
|
@ -9,8 +9,6 @@ class EmailFormatValidator < ActiveModel::EachValidator
|
||||
(v.strip =~ /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i) || v.strip.blank?
|
||||
end
|
||||
|
||||
if results.include?(false)
|
||||
record.errors[attribute] << (options[:message] || "is not formatted properly")
|
||||
end
|
||||
record.errors[attribute] << (options[:message] || "is not formatted properly") if results.include?(false)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user