2021-05-11 13:34:23 +02:00
|
|
|
// Third party imports
|
2021-05-15 11:50:13 +02:00
|
|
|
import { validatePerson, validateVcard } from '@cicnet/schemas-data-validator';
|
2021-04-27 13:20:18 +02:00
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
/**
|
|
|
|
* Validates a person object against the defined Person schema.
|
|
|
|
*
|
|
|
|
* @param person - A person object to be validated.
|
|
|
|
*/
|
2021-04-27 13:20:18 +02:00
|
|
|
async function personValidation(person: any): Promise<void> {
|
2021-04-29 19:10:39 +02:00
|
|
|
const personValidationErrors: any = await validatePerson(person);
|
2021-04-27 13:20:18 +02:00
|
|
|
|
|
|
|
if (personValidationErrors) {
|
2021-05-18 12:24:41 +02:00
|
|
|
personValidationErrors.map((error) => console.error(`${error.message}`, person, error));
|
2021-04-27 13:20:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
/**
|
|
|
|
* Validates a vcard object against the defined Vcard schema.
|
|
|
|
*
|
|
|
|
* @param vcard - A vcard object to be validated.
|
|
|
|
*/
|
2021-04-27 13:20:18 +02:00
|
|
|
async function vcardValidation(vcard: any): Promise<void> {
|
2021-04-29 19:10:39 +02:00
|
|
|
const vcardValidationErrors: any = await validateVcard(vcard);
|
2021-04-27 13:20:18 +02:00
|
|
|
|
|
|
|
if (vcardValidationErrors) {
|
2021-05-18 12:24:41 +02:00
|
|
|
vcardValidationErrors.map((error) => console.error(`${error.message}`, vcard, error));
|
2021-04-27 13:20:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
/** @exports */
|
2021-05-10 18:15:25 +02:00
|
|
|
export { personValidation, vcardValidation };
|