[bug] Fix ProfileData
This commit is contained in:
parent
24a8be727c
commit
d5088d9e36
@ -1,4 +1,4 @@
|
||||
import type { FileBlob } from "./Data";
|
||||
import { isFileBlob, type FileBlob } from "./Data";
|
||||
import type { RoleDefinition } from "./Roles";
|
||||
|
||||
export interface ProfileData {
|
||||
@ -18,20 +18,36 @@ export function isProfileData(data: any): data is ProfileData{
|
||||
if (typeof data !== 'object' || data === null) return false;
|
||||
|
||||
const requiredStringFields = [
|
||||
'folderNumber',
|
||||
'name',
|
||||
'deedType',
|
||||
'description',
|
||||
'archived_description',
|
||||
'status',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
'surname',
|
||||
'email',
|
||||
'phone',
|
||||
'address',
|
||||
'postalCode',
|
||||
'city',
|
||||
'country',
|
||||
];
|
||||
|
||||
for (const field of requiredStringFields) {
|
||||
if (typeof data[field] !== 'string') return false;
|
||||
}
|
||||
|
||||
const requiredBooleanFields = [
|
||||
'idCertified',
|
||||
];
|
||||
|
||||
for (const field of requiredBooleanFields) {
|
||||
if (typeof data[field] !== 'boolean') return false;
|
||||
}
|
||||
|
||||
const requiredFileFields = [
|
||||
'idDocument',
|
||||
];
|
||||
|
||||
for (const field of requiredFileFields) {
|
||||
if (!isFileBlob(data[field]) && data[field] !== null) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -64,6 +80,11 @@ export interface ProfileCreated {
|
||||
|
||||
export function setDefaultProfileRoles(ownerId: string[], validatorId: string): Record<string, RoleDefinition> {
|
||||
return {
|
||||
demiurge: {
|
||||
members: [...ownerId, validatorId],
|
||||
validation_rules: [],
|
||||
storages: []
|
||||
},
|
||||
owner: {
|
||||
members: ownerId,
|
||||
validation_rules: [
|
||||
|
Loading…
x
Reference in New Issue
Block a user