Tech: deleguer le casting referentiel aux PrefillTypeDeChamp#13490
Merged
Conversation
Accept textual variants ("monsieur", "m", "male", "homme",
"mademoiselle", "female", "femme", etc.) and normalize them
to the canonical "M." / "Mme" values — matching the behavior
of ReferentielChamp#call_caster.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PrefillDateTypeDeChamp now handles Numeric values (Integer and Float unix timestamps) and string-encoded timestamps alongside regular date strings — matching the behavior of ReferentielChamp#call_caster. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PrefillNumberTypeDeChamp now truncates Float values to Integer for integer_number fields (e.g. 42.2 → "42") — matching the behavior of ReferentielChamp#call_caster. Also documents that Integer values already work for decimal_number fields. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace cast_value_for_type_de_champ with delegation to PrefillTypeDeChamp#to_assignable_attributes, so referentiel and URL prefill share the same normalization and validation logic. call_caster is kept for cast_displayable_values (display-only types like :boolean, :array, :string). Behavior changes: - decimal_number with integer input stores "2" instead of "2.0" - multiple_drop_down_list rejects values not in options - address prefill now sets value alongside external_id Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Now that champ prefill delegates to PrefillTypeDeChamp, the old call_caster only serves cast_displayable_values. Remove the 10 dead champ-type branches (drop_down_list, multiple_drop_down_list, checkbox, yes_no, text, textarea, etc.) and rename to cast_display_value to reflect its sole purpose. The 7 remaining branches match the display types defined in Referentiels::MappingFormComponent::TYPES. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mfo
force-pushed
the
prefill-referentiel-compat
branch
from
July 17, 2026 13:44
b4c0788 to
f295459
Compare
tchak
approved these changes
Jul 17, 2026
Merged
via the queue into
demarche-numerique:main
with commit Jul 17, 2026
4e3429e
32 of 33 checks passed
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.
Probleme
ReferentielChamp#call_casterdupliquait la logique de normalisation et validation que lesPrefillTypeDeChampgerent deja pour le prefill URL : conversion de dates, formatting de nombres, validation d'options dropdown, normalisation de civilite, etc. Deux chemins de code distincts pour le meme objectif (caster une valeur brute vers un champ).Solution
Enrichir les
PrefillTypeDeChamppour accepter les memes inputs que les APIs referentiel, puis deleguerupdate_prefillable_champaPrefillTypeDeChamp#to_assignable_attributesau lieu decall_caster.Enrichissements prefill :
PrefillCiviliteTypeDeChamp: fuzzy matching ("monsieur","male","femme", etc.)PrefillDateTypeDeChamp: timestamps unix (Integer, Float, String) pour date et datetimePrefillNumberTypeDeChamp: tronquer les Float en Integer pourinteger_numberSwap :
update_prefillable_champdelegue aPrefillTypeDeChamp.build(tdc, revision).to_assignable_attributes(champ, value)avec une pre-normalisationnormalize_api_valuepour le casdrop_down_list+ Array.Cleanup :
call_casterrenomme encast_display_value, reduit de 17 a 7 branches (seuls les types d'affichage JSONB restent).Changements de comportement
decimal_numberavec input entier : stocke"2"au lieu de"2.0"multiple_drop_down_list: rejette les valeurs hors options (screening au lieu de validation ulterieure)address: setvalue+external_id(la resolution BAN ecrasevalueensuite)Generated with Claude Code