@ -69,14 +69,6 @@ namespace :generate_documentation do
type::string,
type::string,
description:"A human-readbale description of the validation",
description:"A human-readbale description of the validation",
},
},
conditions:{
type::array,
description:"A list of conditions that must be met for this validation to run, in human-readable text (not code)",
items:{
type::string,
description:"A single condition (write this in a human-readable way)",
},
},
cases:{
cases:{
type::array,
type::array,
description:"A list of cases that this validation triggers on, each with specific details",
description:"A list of cases that this validation triggers on, each with specific details",
@ -122,14 +114,128 @@ namespace :generate_documentation do
},
},
other_validated_models:{
other_validated_models:{
type::string,
type::string,
description:"Comma separated list of any other models (other than log) that were used in this validation. These are possible models: user, organisation, scheme, location, organisation_relationship. Only leave this blank if no other models were used in this validation.",
description:"Comma separated list of any other models (other than log) that were used in this validation. These are possible models (only add a value to this field if other validation models are one of these models): User, Organisation, Scheme, Location, Organisation_relationship, LaRentRange. Only leave this blank if no other models were used in this validation.",
content:"You write amazing documentation, as a senior technical writer. Your audience is non-technical team members. You have been asked to document the validations in a Rails application. The application collects social housing data for different collection years. There are validations on different fields, sometimes the validations depend on several fields.
description:"Use this function to save the complete documentation, covering given validation in the provided code.",
parameters:{
type::object,
properties:{
description:{
type::string,
description:"A human-readbale description of the validation",
},
from:{
type::number,
description:"the year from which the validation starts. If this validation runs for logs with a startdate after a certain year, specify that year here, only if it is not specified in the validation method, leave this field blank",
},
to:{
type::number,
description:"the year in which the validation ends. If this validation runs for logs with a startdate before a certain year, specify that year here, only if it is not specified in the validation method, leave this field blank",
},
validation_type:{
type::string,
enum:%w[presence format minimum maximum range inclusion length other],
description:"The type of validation that is being performed. This should be one of the following: presence (validates that the question is answered), format (validates that the answer format is valid), minimum (validates that entered value is more than minimum allowed value), maximum (validates that entered value is less than maximum allowed value), range (values must be between two values), inclusion (validates that the values that are not allowed arent selected), length (validates the length of the answer), other",
},
other_validated_models:{
type::string,
description:"Comma separated list of any other models (other than log) that were used in this validation. These are possible models (only add a value to this field if other validation models are one of these models): User, Organisation, Scheme, Location, Organisation_relationship, LaRentRange. Only leave this blank if no other models were used in this validation.",
Rails.logger.info("Validation #{validation_depends_on_hash.keys.first} already exists for #{page_the_validation_applied_to.questions.first.id} for start year #{form.start_date.year}")
"{\n\"description\": \"Validates the format.\",\n\"conditions\": [\n\"The validation runs if the previous postcode is known.\"\n ],\n\"cases\": [\n {\n\"case_description\": \"Previous postcode is known and current postcode is blank\",\n\"errors\": [\n {\n\"error_message\": \"Enter a valid postcode\",\n\"field\": \"ppostcode_full\"\n }\n ],\n\"validation_type\": \"format\"\n }]\n}"}}]},}]}
"{\n\"description\": \"Validates the format.\",\n\"cases\": [\n {\n\"case_description\": \"Previous postcode is known and current postcode is blank\",\n\"errors\": [\n {\n\"error_message\": \"Enter a valid postcode\",\n\"field\": \"ppostcode_full\"\n }\n ],\n\"validation_type\": \"format\",\n\"other_validated_models\": \"User\" }]\n}"}}]}}]}
end
end
beforedo
beforedo
@ -21,6 +21,7 @@ RSpec.describe "generate_documentation" do
context"when the rake task is run"do
context"when the rake task is run"do
it"creates new validation documentation records"do
it"creates new validation documentation records"do