Rename auditors module.
This commit is contained in:
parent
73f8f8dea3
commit
709b3356c7
3 changed files with 2 additions and 101 deletions
|
@ -1,99 +0,0 @@
|
||||||
import {
|
|
||||||
type Audit,
|
|
||||||
auditChain,
|
|
||||||
auditRequire,
|
|
||||||
auditString,
|
|
||||||
auditTest,
|
|
||||||
auditOptions,
|
|
||||||
} from "@auditors/core"
|
|
||||||
|
|
||||||
export const auditId = auditChain(
|
|
||||||
auditString,
|
|
||||||
auditTest((id) => id.length === 20, "Invalid length for ID"),
|
|
||||||
)
|
|
||||||
|
|
||||||
export function auditVersions(
|
|
||||||
audit: Audit,
|
|
||||||
dataUnknown: unknown,
|
|
||||||
): [unknown, unknown] {
|
|
||||||
if (dataUnknown == null) {
|
|
||||||
return [dataUnknown, null]
|
|
||||||
}
|
|
||||||
if (typeof dataUnknown !== "object") {
|
|
||||||
return audit.unexpectedType(dataUnknown, "object")
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = { ...dataUnknown }
|
|
||||||
const errors: { [key: string]: unknown } = {}
|
|
||||||
const remainingKeys = new Set(Object.keys(data))
|
|
||||||
|
|
||||||
audit.attribute(
|
|
||||||
data,
|
|
||||||
"VERSION",
|
|
||||||
true,
|
|
||||||
errors,
|
|
||||||
remainingKeys,
|
|
||||||
auditVersionsVersion,
|
|
||||||
auditRequire,
|
|
||||||
)
|
|
||||||
|
|
||||||
return audit.reduceRemaining(data, errors, remainingKeys)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function auditVersionsVersion(
|
|
||||||
audit: Audit,
|
|
||||||
dataUnknown: unknown,
|
|
||||||
): [unknown, unknown] {
|
|
||||||
if (dataUnknown == null) {
|
|
||||||
return [dataUnknown, null]
|
|
||||||
}
|
|
||||||
if (typeof dataUnknown !== "object") {
|
|
||||||
return audit.unexpectedType(dataUnknown, "object")
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = { ...dataUnknown }
|
|
||||||
const errors: { [key: string]: unknown } = {}
|
|
||||||
const remainingKeys = new Set(Object.keys(data))
|
|
||||||
|
|
||||||
audit.attribute(
|
|
||||||
data,
|
|
||||||
"@id",
|
|
||||||
true,
|
|
||||||
errors,
|
|
||||||
remainingKeys,
|
|
||||||
auditId,
|
|
||||||
auditRequire,
|
|
||||||
)
|
|
||||||
audit.attribute(
|
|
||||||
data,
|
|
||||||
"@fin",
|
|
||||||
true,
|
|
||||||
errors,
|
|
||||||
remainingKeys,
|
|
||||||
auditString,
|
|
||||||
auditOptions(["2999-01-01"]),
|
|
||||||
auditRequire,
|
|
||||||
)
|
|
||||||
audit.attribute(
|
|
||||||
data,
|
|
||||||
"@etat",
|
|
||||||
true,
|
|
||||||
errors,
|
|
||||||
remainingKeys,
|
|
||||||
auditString,
|
|
||||||
auditOptions([""]),
|
|
||||||
auditRequire,
|
|
||||||
)
|
|
||||||
audit.attribute(
|
|
||||||
data,
|
|
||||||
"@debut",
|
|
||||||
true,
|
|
||||||
errors,
|
|
||||||
remainingKeys,
|
|
||||||
auditString,
|
|
||||||
auditOptions(["2999-01-01"]),
|
|
||||||
auditRequire,
|
|
||||||
)
|
|
||||||
|
|
||||||
return audit.reduceRemaining(data, errors, remainingKeys)
|
|
||||||
}
|
|
|
@ -7,7 +7,7 @@ import path from "path"
|
||||||
import type { JSONValue } from "postgres"
|
import type { JSONValue } from "postgres"
|
||||||
import sade from "sade"
|
import sade from "sade"
|
||||||
|
|
||||||
import { auditId, auditVersions } from "$lib/auditors/data"
|
import { auditId, auditVersions } from "$lib/auditors/legal"
|
||||||
import type {
|
import type {
|
||||||
Article,
|
Article,
|
||||||
Jo,
|
Jo,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import path from "path"
|
||||||
import type { JSONValue } from "postgres"
|
import type { JSONValue } from "postgres"
|
||||||
import sade from "sade"
|
import sade from "sade"
|
||||||
|
|
||||||
import { auditId, auditVersions } from "$lib/auditors/data"
|
import { auditId, auditVersions } from "$lib/auditors/legal"
|
||||||
import type {
|
import type {
|
||||||
Article,
|
Article,
|
||||||
SectionTa,
|
SectionTa,
|
||||||
|
|
Loading…
Reference in a new issue