Forms
Introduction
In the VA Platform space, the role of form schemas is crucial in ensuring seamless integration and data consistency across different systems. Central to this framework are Vets API and Vets Website, which heavily rely on these schemas for efficient operation. By defining the structure of various forms through these schemas, these systems are able to communicate effectively and maintain uniformity. The vets-json-schema repository plays a pivotal role in this process, serving as the central hub for schema maintenance and updates. It’s important for developers and integrators working in the VA ecospace to understand the importance of defining schemas, especially when dealing with form processing on Vets Website. The following section details the aspects of this process, including model creation, validation techniques, and processing examples.
Schemas
Form Schemas are utilized by both Vets-API and Vets-Website, and allow the two systems to share the structure of a form. This involves specifying fields and types. Schemas are maintained in the Vets-JSON-Schema Repository. Schemas should be defined for integrations that will process a form presented on Vets-Website.
Model
class SavedClaim::Burial < CentralMailClaim
# id of the form, must be the same as the id in the directory name of the associated json schema
# for example the path to this models's schema is vets-json-schema/src/schemas/21P-530/schema.js
FORM = '21P-530'
end
Validation
form = SavedClaim::Burial.new(form: {}.to_json)
form.valid? # => false
form.errors.messages[:form] # => ["The property '#/' of type Hash did not match one or more of the required schemas. The schema specific errors were:\n\n- anyOf #0:\n - The property '#/' did not contain a required property of 'vaFileNumber'\n- anyOf #1:\n - The property '#/' did not contain a required property of 'veteranSocialSecurityNumber'", "The property '#/' did not contain a required property of 'privacyAgreementAccepted' in schema 57d02bcd-7bbe-567e-bc7d-f6ee46bea309", "The property '#/' did not contain a required property of 'claimantAddress' in schema 57d02bcd-7bbe-567e-bc7d-f6ee46bea309", "The property '#/' did not contain a required property of 'veteranFullName' in schema 57d02bcd-7bbe-567e-bc7d-f6ee46bea309"]
Processing
class ClaimsBaseController < ApplicationController
def create
claim = claim_class.new(form: filtered_params[:form])
unless claim.save
raise Common::Exceptions::ValidationErrors, claim
end
# this will queue up a job to process the form and its attachments
# and submit them to the central mail API
claim.process_attachments!
render(json: claim)
end
end
Help and feedback
Get help from the Platform Support Team in Slack.
Submit a feature idea to the Platform.