3. js / modelo / validaPasatiempo.js

1/**
2 * @param { any } objeto
3 * @returns { {
4 * uuid: string,
5 * nombre: string,
6 * modificacion: number,
7 * eliminado: boolean,
8 * } }
9 */
10export function validaPasatiempo(objeto) {
11
12 if (typeof objeto.uuid !== "string")
13 throw new Error("El uuid debe ser texto.")
14
15 if (typeof objeto.nombre !== "string")
16 throw new Error("El nombre debe ser texto.")
17
18 if (typeof objeto.modificacion !== "number")
19 throw new Error("El campo modificacion debe ser número.")
20
21 if (typeof objeto.eliminado !== "boolean")
22 throw new Error("El campo eliminado debe ser booleano.")
23
24 return objeto
25
26}
skip_previous skip_next