2024-10-13 15:25:30 -07:00
|
|
|
import * as v from 'valibot';
|
2024-08-28 04:43:23 -07:00
|
|
|
|
2024-10-14 15:07:22 -07:00
|
|
|
const hexSchema = v.pipe(v.string(), v.regex(/^#[a-f0-9]{6}$/i));
|
2024-08-28 04:43:23 -07:00
|
|
|
|
2024-10-29 14:44:28 -07:00
|
|
|
/**
|
|
|
|
* @category Schemas
|
|
|
|
*/
|
2024-10-13 15:25:30 -07:00
|
|
|
const roleSchema = v.object({
|
|
|
|
id: v.fallback(v.string(), ''),
|
|
|
|
name: v.fallback(v.string(), ''),
|
2024-10-14 15:07:22 -07:00
|
|
|
color: v.fallback(hexSchema, ''),
|
2024-10-13 15:25:30 -07:00
|
|
|
permissions: v.fallback(v.string(), ''),
|
|
|
|
highlighted: v.fallback(v.boolean(), true),
|
2024-08-28 04:43:23 -07:00
|
|
|
});
|
|
|
|
|
2024-11-29 07:01:54 -08:00
|
|
|
/**
|
|
|
|
* @category Entity types
|
|
|
|
*/
|
2024-10-13 15:25:30 -07:00
|
|
|
type Role = v.InferOutput<typeof roleSchema>;
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
export {
|
|
|
|
roleSchema,
|
|
|
|
type Role,
|
|
|
|
};
|