cic-staff-client/src/app/_helpers/schema-validation.ts

32 lines
934 B
TypeScript
Raw Normal View History

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