Skip to content

Validation and input integration

Core 3 is deliberately independent from form and validation libraries.

small/forms is no longer a Core dependency and AbstractManager::getForm() was removed in 3.0. The previous integration could not remain in Core because the current Small runtime dependency graph uses small/collection 4.0.*, while the former forms integration targeted the previous collection generation.

Validate external input in your application or framework layer, then apply validated values to the entity before persistence:

/** @var UserEntity $user */
$user = $userManager->newEntity();

if (!is_string($requestBody['username'] ?? null) || trim($requestBody['username']) === '') {
    throw new InvalidArgumentException('username is required');
}

$user->setUsername(trim($requestBody['username']));
$user->persist();

In a framework application, prefer the framework's validator, DTO or form component and inject EntityManagerFactoryInterface only into the persistence/application service that needs to create or load managers.

The ORM does not automatically validate an entity during persist(). This keeps Core focused on persistence and lets each integration choose its own input-validation policy.

For partial database updates that do not require entity-level validation or lifecycle handling, use the update builder.

Next chapter: Database layers