Skip to content

[Feature Request] Validate program end date is not before start date #1515

@golanglemonade

Description

@golanglemonade

A program has a StartDate and EndDate however, there is no validation to ensure the EndDate is after the StartDate.

Add Hook

  1. add hook to program hooks called HookProgramValidation
  2. hook should run on the follow Op.Type: OpCreate, OpUpdateorOpUpdateOne`
  3. if m.EndDate() is set, then check the following in this order:
			m.StartDate() // see if date is being set
			m.StartDateCleared() // if not set, see if its being cleared
			m.OldStartDate(ctx) // if not cleared, get the old start date
  1. If start date is also being set, ensure end date is after
  2. if start date is cleared but not set, skip check
  3. if neither are on the mutation, get the old start date - if that is not empty, ensure the end date is after

Add hook to schema

Once the hook is written, add the hook to the programs schema and run

task generate

Add Tests:

Either:

  • write hook tests
    and/or:
  • update and/or add tests to the internal/graphapi/programs_test.go to ensure the validation is correct

Metadata

Metadata

Labels

enhancementNew feature or requestgoPull requests that update go codegood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions