Validation for DB model objects representing job params

Registered by Lars Butler

In our job parameters model (OqJobProfile in code, uiapi.oq_job_profile in the database), there is a need for doing a significant amount of validation. In the job profile, we have--at the moment--about 75
parameters. The need for a robust and complete validation facility should be obvious.

The patterns we put in place with respect to the job profile validation could be extended to other models as well. At the moment, however, the urgency lies solely in validating the job parameter model.

After having a short technical discussion, here's what we came up with.

--Types of Validation--

We are breaking the concept of validation into two categories:
- Simple validation
  Examples:
  - imt (intensity measure type) should be one of (pga, sa, pgv, pgd, ia, rsd, mmi)
  - investigation_time should be > 0.0
- Context-sensitive validation
  Examples:
   - if imt is 'sa': period and damping must be defined; else, period and damping can/should be null
   - if calculation_mode is 'uhs': imt must default to 'sa', period can/should be null, damping must be defined, and uhs_periods must be defined

--Implementation of Validation--

As noted above, simple validation rules apply to the value of a single field. One way to implement this would be to define validators (where required) for each field in the Django model class. More about model field validators: https://docs.djangoproject.com/en/dev/ref/forms/validation/#using-validators.

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.