denosyscore / validation
Validation engine and rules
Requires
- php: ^8.2
- denosyscore/contracts: ^0.2
- denosyscore/database: ^0.2 || ^0.3 || ^0.4
- nesbot/carbon: ^2.72 || ^3.0
- psr/http-message: ^2.0
Requires (Dev)
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^10.5
Suggests
None
Provides
None
Conflicts
- denosyscore/http: <0.3.2
Replaces
None
- dev-main
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.0
- dev-codex/remove-http-exception-adapter
- dev-codex/database04-compat
- dev-codex/carbon-date-rule-dependency
- dev-codex/rule-parameter-types
- dev-codex/database03-release-compat
- dev-codex/direct-validation-messages
- dev-codex/psr-http-message-dependency
- dev-codex/unique-ignore-id
- dev-codex/keyed-validation-exception
- dev-codex/http-upload-provenance
- dev-codex/validation-rule-integration
- dev-codex/typed-db-rule-binding
- dev-codex/regex-parameter-binding
- dev-codex/confirmed-field-errors
- dev-codex/validation-rule-contracts
This package is auto-updated.
Last update: 2026-11-03 20:08:39 UTC
README
Validation engine and rules
Status
Initial extraction snapshot from denosyscore monorepo as of 2026-02-14.
Installation
composer require denosyscore/validation
Included Modules
- src/Validation/*
Database-backed rules
The unique and exists rules resolve the database package's
Denosys\Database\Connection\Connection binding lazily when a rule first
runs. The legacy db binding remains a fallback. When both bindings are
present, the typed connection takes precedence. Register the database provider
before validating with these rules.
The date, before, and after rules use Carbon. Composer installs the
declared Carbon runtime dependency with validation; consumers do not need to
install it separately.
Direct field errors
When a field-specific failure is discovered after ordinary rule validation, raise it without constructing an empty validator in the caller:
throw \Denosys\Validation\ValidationException::withMessages([ 'email' => 'The email address is unavailable.', ]);
Values may be a string or a non-empty list of strings. The existing
ValidationException(Validator $validator) constructor remains supported.
The unique:accounts,email,1 rule checks the email column in accounts
while excluding the row with id = 1. Its third positional parameter is
named ignore_id by Unique::parameterNames().
HTTP exception responses
Validation itself does not depend on HTTP. Install denosyscore/http v0.3.2
or later for Denosys\Http\Exceptions\ValidationExceptionHandler. HTTP also
provides the former Denosys\Validation\Handlers\ValidationExceptionHandler
name as an alias for existing integrations. Composer prevents pairing this
validation release with an older HTTP version that lacks the alias.
HTTP-uploaded files
The file rule accepts valid PSR-7 uploads from any source. Add
http_uploaded when a browser-facing form must require a file received by
PHP's HTTP upload handling:
$validator = Validator::make( ['document' => $uploadedFile], ['document' => 'required|file|http_uploaded|mimes:jpg,png,pdf'], );
The rule checks a successful, nonempty upload and calls is_uploaded_file()
on its stream path. It is intended for validation before moving the upload.
Development
composer validate --strict find src tests -type f -name '*.php' -print0 | xargs -0 -n1 php -l composer test composer analyse
RuleInterface::validate() and message() receive named parameters from the
validator. Parameter values may include numbers, null, or lists; rules that
support direct positional calls may also receive integer keys. The static
analysis fixture checks this public parameter contract.
CI Workflows
- CI: Composer validation, isolated installation, PHP 8.2/8.5 tests against Carbon 2/3 and database 0.2/0.3/0.4, static analysis of rule parameter consumers, and syntax lint on push and pull requests.
- Release: GitHub release publication on semantic version tags.
- Dependabot: weekly Composer dependency update checks.
Releases
CI tests against database v0.2.3, v0.3.0, and v0.4.0. After CI passes on main, create
an annotated semantic version tag from that reviewed commit and push it. The
Release workflow publishes a GitHub Release. Confirm the matching version is
available in the Composer package index before updating consumers.