-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcv-template-options.ts
More file actions
30 lines (24 loc) · 939 Bytes
/
cv-template-options.ts
File metadata and controls
30 lines (24 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
export const CV_TEMPLATE_OPTIONS = [
{ id: 'default', label: 'Default' },
{ id: 'executive', label: 'Executive' },
{ id: 'minimal', label: 'Minimal' },
{ id: 'serif', label: 'Serif' }
] as const;
export type CvTemplateId = (typeof CV_TEMPLATE_OPTIONS)[number]['id'];
export const DEFAULT_CV_TEMPLATE_ID: CvTemplateId = 'default';
const CV_TEMPLATE_ID_SET: ReadonlySet<string> = new Set(CV_TEMPLATE_OPTIONS.map((template) => template.id));
/**
* Determina si un string pertenece al catálogo de plantillas soportadas.
*/
export const isCvTemplateId = (value: string): value is CvTemplateId => {
return CV_TEMPLATE_ID_SET.has(value);
};
/**
* Normaliza valores externos al id de plantilla por defecto.
*/
export const toCvTemplateId = (value: string | null | undefined): CvTemplateId => {
if (typeof value !== 'string') {
return DEFAULT_CV_TEMPLATE_ID;
}
return isCvTemplateId(value) ? value : DEFAULT_CV_TEMPLATE_ID;
};