PHP validation library inspired by Valibot and Zod. Type-safe, fluent API for primitives, arrays, and objects.
Core validation logic lives in src/Lemmon/Validator/. Tests in tests/ follow XValidatorTest.php naming. Key project files:
llms.txt- Technical spec for external/consumer use; API signatures, null handling, transformation typesROADMAP.md- Strategic planning and checkboxesTASKS.md- Immediate task pool (keep short, no numbering)CHANGELOG- Completed workIDEAS- Exploration
- Namespace:
Lemmon\Validator(runtime),Lemmon\Tests(tests) - Core:
Validatorstatic factory;FieldValidatorbase;ValidationExceptionfor errors - Validators:
isString,isInt,isFloat,isBool,isArray,isAssociative,isObject - Shared:
NumericConstraintsTrait(min, max, multipleOf, etc.);PipelineTypeenum; variant enumsIpVersion,Base64Variant,UuidVariantfor format methods - String formats: email, URL, UUID, IP, hostname, domain, time, base64, hex, regex, datetime, date
- Schema validation: AssociativeValidator/ObjectValidator with nested error aggregation; shared
SchemaValidatorOptionsTrait(coerceAll,passthrough, schema clone helper);passthrough()keeps undeclared keys/properties (unvalidated); default output is schema keys only - Logical combinators:
Validator::allOf,anyOf,not; instancesatisfiesAny,satisfiesAll,satisfiesNone;const()for single allowed value;enum()for BackedEnum - Behavior: Optional by default (null allowed unless
required()); form-safe coercion (empty string → null, not 0/false); pipeline order guaranteed; fail-fast per field;satisfies()accepts validators or callables with(value, key, input); extend viasatisfies(), not custom validators
composer test- Run Pest test suitecomposer lint/composer format- Mago linting and formatting (dev dependency)composer analyse- PHPStan at max levelcomposer platform-check- Verify PHP 8.3 and extension requirementscomposer check- Run all checks (platform, format, lint, Prettier, test, analyse); use before PRnpm run format- Prettier for YAML, JSON, Markdownnpm run check- Alias forcomposer check- Pre-commit hook (Husky): Prettier check, Mago format --staged, Mago lint --staged
config.platform.php is set to 8.3.0 so dependency resolution targets PHP 8.3; composer update/install will not add packages that require PHP above 8.3.
Dev tooling: symfony/var-dumper, symfony/error-handler, ergebnis/composer-normalize.
PSR-12 for PHP. Mago for lint/format (composer lint, composer format). Prettier (.prettierrc) for YAML, JSON, Markdown. Add PHPDoc where behavior is non-obvious. Stick to ASCII punctuation in code and docs (e.g. -- not em dash) so diffs stay predictable. Emojis sparingly.