You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.8 KiB
36 lines
1.8 KiB
const fs = require('fs');
|
|
const rules = require('./conditional-rules.js');
|
|
|
|
const answers = {
|
|
"family_background.do_you_currently_have_an_ongoing_financial_caregiving_or_guardianship_responsibility_for_a_family_member": {
|
|
value: "i_am_responsible_for_caring_for_my_parent(s)_(father,_mother,_or_both).",
|
|
option_id: "family_background.do_you_currently_have_an_ongoing_financial_caregiving_or_guardianship_responsibility_for_a_family_member.i_am_responsible_for_caring_for_my_parent_s_father_mother_or_both"
|
|
}
|
|
};
|
|
|
|
const visibility = {
|
|
"operator": "any_of",
|
|
"parent_question_id": "family_background.do_you_currently_have_an_ongoing_financial_caregiving_or_guardianship_responsibility_for_a_family_member",
|
|
"trigger_option_ids": [
|
|
"family_background.do_you_currently_have_an_ongoing_financial_caregiving_or_guardianship_responsibility_for_a_family_member.i_am_responsible_for_caring_for_my_parent_s_father_mother_or_both"
|
|
],
|
|
"clear_answer_when_hidden": true
|
|
};
|
|
|
|
const context = { age: 25, gender: 'male' };
|
|
|
|
const question = {
|
|
id: "family_background.additional_details_about_family_responsibility",
|
|
required: false,
|
|
baseRequired: false, // in backend DYNAMIC_REQUIRED sets is_required=True, but what does the schema send?
|
|
isVisible: true,
|
|
conditionalRule: visibility,
|
|
visibility: visibility,
|
|
};
|
|
|
|
// Wait, the API sends `required: true` and `is_required: true` when it's dynamically required!
|
|
// See check_form_section.py output: family_background.additional_details_about_family_responsibility - is_visible=True is_required=True
|
|
question.required = true;
|
|
question.baseRequired = true; // Wait, schema adapter does baseRequired: bq.required, and required: bq.is_required !== undefined ? bq.is_required : bq.required
|
|
|
|
console.log("Is additional_details required?", rules.isQuestionRequired(question, answers, context));
|