Skip to content

Transition to answers part 5: JSON schema validation - #14625

Open
sebastienhoorens wants to merge 6 commits into
custom-field-answer-value-readsfrom
move-user-values-schema-validation
Open

Transition to answers part 5: JSON schema validation#14625
sebastienhoorens wants to merge 6 commits into
custom-field-answer-value-readsfrom
move-user-values-schema-validation

Conversation

@sebastienhoorens

@sebastienhoorens sebastienhoorens commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

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

  • [TAN-7640] Partial validation of idea/survey fields on submission.

sebastienhoorens and others added 2 commits August 20, 2026 13:05
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>
@cl-dev-bot

cl-dev-bot commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator
Warnings
⚠️ The PR title contains no Jira issue key (case-sensitive)
⚠️ The branch name contains no Jira issue key (case-sensitive)
Messages
📖 Changelog provided 🎉
📖

Run the e2e tests

📖 Check translation progress

Generated by 🚫 dangerJS against 24575a2

@sebastienhoorens
sebastienhoorens changed the base branch from master to custom-field-answer-value-reads August 20, 2026 11:13
sebastienhoorens and others added 3 commits August 20, 2026 15:21
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>
end

# Mutates `params` to shape them for permitting, like the create action does inline.
def prepare_update_params(input)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted this into a method because of the Rubocop offense on method length (update).

Comment thread back/app/models/user.rb
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@sebastienhoorens sebastienhoorens Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants