add erreur message in modal CI" - #1131
Conversation
Signed-off-by: Frédéric Madranges <frederic.madranges_externe@rte-france.com>
There was a problem hiding this comment.
Pull request overview
This PR improves validation feedback in the Initial Condition modal by adding inline error messages (PrimeNG p-message) and wiring inputs to accessibility attributes (aria-invalid, aria-errormessage), with shared constraints/validators and i18n strings.
Changes:
- Added shared helpers for integer validation and building
aria-errormessageid lists. - Centralized min/max constraints and updated the modal form validators to reuse them.
- Updated the modal template to display min/max/integer error messages and added new i18n key(s) for the integer requirement.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/app/shared/components/initial-condition-modal/initialConditionModal.helpers.ts | Adds reusable validators/helpers (integerValidator, getErrorIds) to support error rendering + aria-errormessage. |
| src/app/shared/components/initial-condition-modal/initialConditionModal.helpers.spec.ts | Adds unit tests for the new helper functions. |
| src/app/shared/components/initial-condition-modal/initialConditionModal.constantes.ts | Introduces centralized min/max constraints for initial condition fields. |
| src/app/shared/components/initial-condition-modal/initialConditionModal.component.ts | Reworks validators to use shared constraints and adds methods to expose aria-errormessage ids. |
| src/app/shared/components/initial-condition-modal/initialConditionModal.component.html | Displays inline min/max/integer errors and connects inputs to aria-invalid/aria-errormessage. |
| public/i18n/en.json | Adds English translation for the “whole number required” error. |
| public/i18n/fr.json | Adds French translation for the “whole number required” error. |
Suppressed comments (2)
src/app/shared/components/initial-condition-modal/initialConditionModal.component.ts:28
- The
validatorsconstant is declared in the component file. In this repo, component files should only contain the Angular metadata + class; constants/helpers should be externalized into*.constantes.ts/*.helpers.tsfor testability and to keep components slim.
/** Form validation rules for initial condition fields. */
const validators = {
name: ['', [Validators.required, Validators.maxLength(40)]],
base_parameters: [
null,
src/app/shared/components/initial-condition-modal/initialConditionModal.helpers.spec.ts:49
- This test says it covers “multiple errors” but the setup only triggers the
integererror, so it never validates the space-joined id behavior. Either adjust the description or make the setup produce 2 active errors.
it('should return several ids joined with a space when multiple errors are active', () => {
const form = fb.group({ base_temperature: [15.5, [Validators.min(-50), integerValidator]] });
expect(getErrorIds(form, 'base_temperature', ['min', 'integer'])).toBe('base_temperature-error-integer');
});
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Frédéric Madranges <frederic.madranges_externe@rte-france.com>
|



Please check if the PR fulfills these requirements
800
add message error on input in modal Initial Condition