
Syncable Entity Builder And Validation
Contributing to the Twenty codebase itself (twentyhq/twenty server internals), not for...
Install
npx skills add twentyhq/twenty --skill syncable-entity-builder-and-validation -g -a claude-code -y- Repository
- twentyhq/twenty60.3k
- Category
- Business
- Updated
- 3d ago
- License
- See repository
- Context cost
- Mediumabout 3,000 tokens
- Runs scripts
- No, instructions only
What it does
Contributing to the Twenty codebase itself (twentyhq/twenty server internals), not for building apps on top of Twenty. Create validation logic and migration action builders for syncable entities in Twenty. Use when implementing business rule validation, uniqueness checks, foreign key validation, or building workspace migration actions for syncable entities. Validators never throw and never mutate.
Syncable Entity: Builder & Validation (Step 3/6)
Purpose: Implement business rule validation and create migration action builders.
When to use: After completing Steps 1-2 (Types, Cache, Transform). Required before implementing action handlers.
Quick Start
This step creates:
- Validator service (business logic validation)
- Builder service (action creation)
- Orchestrator wiring (CRITICAL - often forgotten!)
Key principles:
- Validators never throw - return error arrays
- Validators never mutate - pass optimistic entity maps
- Use indexed lookups (O(1)) not
Object.values().find()(O(n))
Step 1: Create Validator Service
File: src/engine/workspace-manager/workspace-migration/workspace-migration-builder/validators/services/flat-my-entity-validator.service.ts
import { Injectable } from '@nestjs/common';
import { t, msg } from '@lingui/macro';
import { isDefined } from 'twenty-shared/utils';
import { type FlatMyEntity } from 'src/engine/metadata-modules/flat-my-entity/types/flat-my-entity.type';
import { type FlatMyEntityMaps } from 'src/engine/metadata-modules/flat-my-entity/types/flat-my-entity-maps.type';
import { WorkspaceMigrationValidationError } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/validators/types/workspace-migration-validation-error.type';
import { MyEntityExceptionCode } from 'src/engine/metadata-modules/my-entity/exceptions/my-entity-exception-code.enum';
@Injectable()
export class FlatMyEntityValidatorService {
validateMyEntityForCreate(
flatMyEntity: FlatMyEntity,
optimisticFlatMyEntityMaps: FlatMyEntityMaps,
): WorkspaceMigrationValidationError[] {
const errors: WorkspaceMigrationValidationError[] = [];


