Start using keyword parameters
Change Response model to only have one text_value
write tests off of the question.
Question
def check_whether_required?
Should this only be if response_value: empty?
Figure out where this goes
don't need its own method. response.question.required
def validate_response(response_value:)
set error messages(open structs)
This is where the def upper and lower bound validations get called.
It takes the name of the constraint and then knows which of the methods to call in the Constraint model, where there will be 2 methods one for the upper and one for the lower value, using send.
TypeQuestions
def is_correct_type?(response_value:)
define error messages
def translate(response_value:)
check if value exists
check type matches
cast the response_value
TypeConstraints
def upper and lower bounds validations(constraint_question_value:, response_value:)
ex. IntegerConstraint - def validate_maximum_value(cq_value:, translated_response_value)
Response
def validate_against_constraint
error handling
calls self.quetion.validate_response(value: self.value)
Random questions
If not required accept empty or set a default of not answered (set constant?)
Maybe this can be handled within response. (question.required?)
Question combines all error messages from constraints(service?)
Confirm unique combination of question and constraint in constraint_questions.