[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";
|
import type { RoleDefinition } from "./Roles";
|
||||||
|
|
||||||
export interface ProfileData {
|
export interface ProfileData {
|
||||||
@ -18,20 +18,36 @@ export function isProfileData(data: any): data is ProfileData{
|
|||||||
if (typeof data !== 'object' || data === null) return false;
|
if (typeof data !== 'object' || data === null) return false;
|
||||||
|
|
||||||
const requiredStringFields = [
|
const requiredStringFields = [
|
||||||
'folderNumber',
|
|
||||||
'name',
|
'name',
|
||||||
'deedType',
|
'surname',
|
||||||
'description',
|
'email',
|
||||||
'archived_description',
|
'phone',
|
||||||
'status',
|
'address',
|
||||||
'created_at',
|
'postalCode',
|
||||||
'updated_at'
|
'city',
|
||||||
|
'country',
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const field of requiredStringFields) {
|
for (const field of requiredStringFields) {
|
||||||
if (typeof data[field] !== 'string') return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +80,11 @@ export interface ProfileCreated {
|
|||||||
|
|
||||||
export function setDefaultProfileRoles(ownerId: string[], validatorId: string): Record<string, RoleDefinition> {
|
export function setDefaultProfileRoles(ownerId: string[], validatorId: string): Record<string, RoleDefinition> {
|
||||||
return {
|
return {
|
||||||
|
demiurge: {
|
||||||
|
members: [...ownerId, validatorId],
|
||||||
|
validation_rules: [],
|
||||||
|
storages: []
|
||||||
|
},
|
||||||
owner: {
|
owner: {
|
||||||
members: ownerId,
|
members: ownerId,
|
||||||
validation_rules: [
|
validation_rules: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user