fix(#131): PATCH fiche AM — NIR sans crash date ni effacement NOT NULL
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
9ad371a342
commit
8ed68797aa
@ -126,9 +126,15 @@ export class AssistantesMaternellesService {
|
|||||||
if (dto.nir !== undefined) {
|
if (dto.nir !== undefined) {
|
||||||
const nirNormalized = dto.nir.replace(/\s/g, '').toUpperCase();
|
const nirNormalized = dto.nir.replace(/\s/g, '').toUpperCase();
|
||||||
if (nirNormalized) {
|
if (nirNormalized) {
|
||||||
|
const dateNaissanceForNir =
|
||||||
|
dto.date_naissance ??
|
||||||
|
(user.date_naissance instanceof Date
|
||||||
|
? user.date_naissance.toISOString().slice(0, 10)
|
||||||
|
: user.date_naissance
|
||||||
|
? String(user.date_naissance).slice(0, 10)
|
||||||
|
: undefined);
|
||||||
const nirValidation = validateNir(nirNormalized, {
|
const nirValidation = validateNir(nirNormalized, {
|
||||||
dateNaissance:
|
dateNaissance: dateNaissanceForNir,
|
||||||
dto.date_naissance ?? user.date_naissance?.toISOString().slice(0, 10),
|
|
||||||
});
|
});
|
||||||
if (!nirValidation.valid) {
|
if (!nirValidation.valid) {
|
||||||
throw new BadRequestException(nirValidation.error || 'NIR invalide');
|
throw new BadRequestException(nirValidation.error || 'NIR invalide');
|
||||||
@ -142,9 +148,8 @@ export class AssistantesMaternellesService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
amPatch.nir = nirNormalized;
|
amPatch.nir = nirNormalized;
|
||||||
} else {
|
|
||||||
(amPatch as { nir?: string | null }).nir = null;
|
|
||||||
}
|
}
|
||||||
|
// NIR vide : ne pas effacer (colonne NOT NULL en BDD) — le front renvoie toujours la clé.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(amPatch).length > 0) {
|
if (Object.keys(amPatch).length > 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user