In a DossierLegislatif, legislature can be empty (after dissolution)
This commit is contained in:
parent
6a24e53eed
commit
af001c8db8
2 changed files with 25 additions and 7 deletions
|
@ -321,7 +321,7 @@ function auditLegislature(
|
||||||
return audit.unexpectedType(dataUnknown, "object")
|
return audit.unexpectedType(dataUnknown, "object")
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = { ...dataUnknown }
|
const data: { [key: string]: unknown } = { ...dataUnknown }
|
||||||
const errors: { [key: string]: unknown } = {}
|
const errors: { [key: string]: unknown } = {}
|
||||||
const remainingKeys = new Set(Object.keys(data))
|
const remainingKeys = new Set(Object.keys(data))
|
||||||
|
|
||||||
|
@ -332,8 +332,9 @@ function auditLegislature(
|
||||||
true,
|
true,
|
||||||
errors,
|
errors,
|
||||||
remainingKeys,
|
remainingKeys,
|
||||||
|
auditTrimString,
|
||||||
|
auditEmptyToNull,
|
||||||
auditDateIso8601String,
|
auditDateIso8601String,
|
||||||
auditRequire,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
audit.attribute(
|
audit.attribute(
|
||||||
|
@ -344,7 +345,6 @@ function auditLegislature(
|
||||||
remainingKeys,
|
remainingKeys,
|
||||||
auditTrimString,
|
auditTrimString,
|
||||||
auditEmptyToNull,
|
auditEmptyToNull,
|
||||||
auditRequire,
|
|
||||||
)
|
)
|
||||||
audit.attribute(
|
audit.attribute(
|
||||||
data,
|
data,
|
||||||
|
@ -352,10 +352,29 @@ function auditLegislature(
|
||||||
true,
|
true,
|
||||||
errors,
|
errors,
|
||||||
remainingKeys,
|
remainingKeys,
|
||||||
auditInteger,
|
auditSwitch(auditInteger, [
|
||||||
auditRequire,
|
auditTrimString,
|
||||||
|
auditEmptyToNull,
|
||||||
|
auditNullish,
|
||||||
|
]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
Object.keys(errors).length === 0 &&
|
||||||
|
data.DATE_DEBUT == null &&
|
||||||
|
data.DATE_FIN == null &&
|
||||||
|
data.LIBELLE == null &&
|
||||||
|
data.NUMERO == null
|
||||||
|
) {
|
||||||
|
return [null, null]
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const key of ["DATE_DEBUT", "DATE_FIN", "LIBELLE", "NUMERO"]) {
|
||||||
|
if (errors[key] !== undefined) {
|
||||||
|
audit.attribute(data, key, true, errors, remainingKeys, auditRequire)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return audit.reduceRemaining(data, errors, remainingKeys)
|
return audit.reduceRemaining(data, errors, remainingKeys)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -627,7 +646,6 @@ function auditMetaDossierLegislatif(
|
||||||
errors,
|
errors,
|
||||||
remainingKeys,
|
remainingKeys,
|
||||||
auditLegislature,
|
auditLegislature,
|
||||||
auditRequire,
|
|
||||||
)
|
)
|
||||||
audit.attribute(
|
audit.attribute(
|
||||||
data,
|
data,
|
||||||
|
|
|
@ -48,7 +48,7 @@ export interface DossierLegislatif {
|
||||||
ID_TEXTE_3?: string // Always starts with JORFTEXT when present
|
ID_TEXTE_3?: string // Always starts with JORFTEXT when present
|
||||||
ID_TEXTE_4?: string // Always starts with JORFTEXT when present
|
ID_TEXTE_4?: string // Always starts with JORFTEXT when present
|
||||||
ID_TEXTE_5?: string // Always starts with JORFTEXT when present
|
ID_TEXTE_5?: string // Always starts with JORFTEXT when present
|
||||||
LEGISLATURE: {
|
LEGISLATURE?: {
|
||||||
DATE_DEBUT: string
|
DATE_DEBUT: string
|
||||||
DATE_FIN: string
|
DATE_FIN: string
|
||||||
LIBELLE: string
|
LIBELLE: string
|
||||||
|
|
Loading…
Reference in a new issue