ksfraser/validation

Small validation helpers and traits (PHP 7.3+) for KS Fraser modules migration.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ksfraser/validation

v0.1.0 2026-02-09 23:07 UTC

This package is auto-updated.

Last update: 2026-02-09 23:18:24 UTC


README

PHP 7.3+ validation helpers and traits intended to replace legacy Origin-style ad-hoc validation during the library split.

Design goals

  • No framework dependencies.
  • Usable from DTOs, repositories, service classes.
  • Prefer composition/traits over deep inheritance.
  • Throw a consistent exception type (ValidationException).

Usage

Static helper

use Ksfraser\Validation\Assert;

Assert::notEmptyString($bankAccountNumber, 'bankAccountNumber');
Assert::stringMaxLen($bankAccountNumber, 255, 'bankAccountNumber');

Trait (thin wrapper over Assert)

use Ksfraser\Validation\Traits\ValidatesStringTrait;

final class Example
{
    use ValidatesStringTrait;

    public function setCode($code)
    {
        $this->assertNotEmptyString($code, 'code');
        $this->assertStringMaxLen($code, 20, 'code');
    }
}

Relationship to the split

This package was introduced as part of the long-running split of a legacy “ksf_modules_common” folder into multiple Composer packages.

If you are working inside that monorepo/workspace, see the local docs there:

  • LIBRARY_SPLIT_ANALYSIS.md
  • repos/fa_classes/MIGRATION_NOTES.md
  • repos/ksf_ModulesDAO/README.md