Make URN mandatory for UK schools and NCES ID mandatory for US schools #638
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make URN mandatory for UK schools and NCES ID mandatory for US schools
Add conditional presence validation for UK URN (reference) and US NCES ID (district_nces_id) fields, with format validation and scoped uniqueness to allow reuse after school rejection. This improves validation error handling so users receive specific, actionable error messages instead of generic form errors.
Status
Closes: https://github.com/orgs/RaspberryPiFoundation/projects/51/views/11?pane=issue&itemId=120513360&issue=RaspberryPiFoundation%7Cdigital-editor-issues%7C780
Related to: (standalone url)
Points for consideration:
Security
What's changed?
Database:
referenceindex to partial unique index (WHERE rejected_at IS NULL)district_nces_idindex to partial unique index (WHERE rejected_at IS NULL)Model (School):
referencerequired for UK (country_code == 'GB')district_nces_idrequired for US (country_code == 'US')united_kingdom?andunited_states?helper methodsAPI Error Responses:
reference"can't be blank"reference"has already been taken"reference"must be 5-6 digits (e.g., 100000)"district_nces_id"can't be blank"district_nces_id"has already been taken"district_nces_id"must be 12 digits (e.g., 010000000001)"Tests:
referencefor default GB schools