UNPKG

@gsb-core/core

Version:

GSB core services and classes for platform-independent web applications

74 lines (73 loc) 3.82 kB
import { GsbEntityDef, GsbProperty } from '../../models/gsb-entity-def.model'; /** * Service for validating Entity Definitions and Properties * Separates validation logic from the main EntityDefService */ export declare class EntityDefValidatorService { private entityService; private static instance; constructor(); static getInstance(): EntityDefValidatorService; /** * Validates that entity definition contains required properties and has valid formatting * @param entityDef The entity definition to validate * @param isCreate Whether this is a create operation (stricter validation) * @throws Error if validation fails with descriptive message */ validateEntityDef(entityDef: GsbEntityDef, isCreate?: boolean): void; /** * Validates a single property * @param property The property to validate * @param isCreate Whether this is a create operation (stricter validation) * @throws Error if validation fails with descriptive message */ validateProperty(property: GsbProperty, isCreate?: boolean): void; /** * Normalize and generate missing values for the entity definition * @param entityDef The entity definition to normalize * @returns A normalized entity definition with all required fields */ normalizeEntityDef(entityDef: GsbEntityDef, tenantCode?: string): GsbEntityDef; /** * Normalize a property with sensible defaults * @param property The property to normalize * @returns Normalized property with defaults applied */ normalizeProperty(property: GsbProperty): GsbProperty; /** * Check if entity name is unique * @param nameToCheck The name to check for uniqueness * @param currentId Optional ID of the entity being updated (to exclude from check) * @param token Optional custom token to use for this request * @param tenantCode Optional custom tenant code to use for this request * @returns Promise resolving to a boolean indicating if the name is unique */ isEntityNameUnique(nameToCheck: string, currentId?: string, token?: string, tenantCode?: string): Promise<boolean>; /** * Check if database table name is unique * @param tableNameToCheck The table name to check for uniqueness * @param currentId Optional ID of the entity being updated (to exclude from check) * @param token Optional custom token to use for this request * @param tenantCode Optional custom tenant code to use for this request * @returns Promise resolving to a boolean indicating if the table name is unique */ isTableNameUnique(tableNameToCheck: string, currentId?: string, token?: string, tenantCode?: string): Promise<boolean>; /** * Check if reference property name is already used in the referenced entity * @param refPropName Reference property name to check * @param refEntityId ID of the referenced entity * @param propertyId Optional ID of the property being updated (to exclude from check) * @param token Optional custom token to use for this request * @param tenantCode Optional custom tenant code to use for this request * @returns Promise with validation result */ isRefPropNameUnique(refPropName: string, refEntityId: string, propertyId?: string, token?: string, tenantCode?: string): Promise<boolean>; /** * Validate property name uniqueness within an entity * @param propertyName Property name to check * @param entityProperties Existing properties in the entity * @param propertyId Optional ID of the property being updated (to exclude from check) * @returns True if the property name is unique */ isPropertyNameUnique(entityDef: GsbEntityDef, propertyName: string, propertyId?: string): Promise<boolean>; }