Transition to answers part 5: JSON schema validation - #14625
Open
sebastienhoorens wants to merge 6 commits into
Open
Transition to answers part 5: JSON schema validation#14625sebastienhoorens wants to merge 6 commits into
sebastienhoorens wants to merge 6 commits into
Conversation
The JSON-schema validation of user custom_field_values moves from a model validation to UserService.upsert_in_web_api, the only place where it could actually trigger. The schemas themselves move from CustomFieldService's metaprogrammed methods into the input type strategies, composed by the new CustomFieldValuesValidationService. The invites xlsx processor now casts cell values through the strategies instead of interpreting the JSON schema. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The *_to_ui_schema_field methods call base_ui_schema_field, which is defined nowhere, so any call would raise. handle_description no longer has callers either. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
|
sebastienhoorens
changed the base branch from
master
to
custom-field-answer-value-reads
August 20, 2026 11:13
Publishing an input (create or update) now validates its custom_field_values against the field schemas, like the registration boundary does for users. Draft saves stay unvalidated, and user field values merged into the input (u_-prefixed keys) are skipped. The update action's params massaging moves into prepare_update_params to keep the method within size limits. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Preload the options for the registration field schemas, remove the dead CustomFieldService#pages, inline the one-caller custom_field_keys, and restructure the validation service spec around a let_it_be field pool. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…schema-validation
| end | ||
|
|
||
| # Mutates `params` to shape them for permitting, like the create action does inline. | ||
| def prepare_update_params(input) |
Contributor
Author
There was a problem hiding this comment.
Extracted this into a method because of the Rubocop offense on method length (update).
| validates :domicile, inclusion: { in: proc { ['outside'] + Area.select(:id).map(&:id) } }, allow_nil: true | ||
| validates :invite_status, inclusion: { in: INVITE_STATUSES }, allow_nil: true | ||
|
|
||
| # NOTE: All validation except for required |
Contributor
Author
There was a problem hiding this comment.
Only happened on submission (on: :form_submission) and therefore moved to the application (controller) layer for consistency.
| # frozen_string_literal: true | ||
|
|
||
| class Invites::XlsxProcessor | ||
| def initialize(error_storage, custom_field_schema) |
Contributor
Author
There was a problem hiding this comment.
The schema was used for coercing the cell value (no JSON schema validation happens at all here) which I argue was the wrong dependency (xlsx formatting and JSON schema validation are two different things): the input type strategy is exactly meant for this.
…schema-validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
More validation with less code. Existing behaviour is preserved, while idea/survey submission is now also validated against the JSON schema (except required fields), only when submitting. Many fields that cannot be picked as registration fields have no validation JSON (existing ones were dead code and had bugs: for example, the text multiloc is not a simple string type).
Changelog
Changed