validation
Skill4 starsChanged 4 months agoMITView on GitHub
Validate data with CakePHP — Validator rules for shape checks during marshalling and application rules for database-aware integrity, applied at the boundary. Use when the user needs rules that depend on the database, such as uniqueness or foreign-key existence, checked before a save commits; the user wants a custom validation rule, a named validation set, or a rule that applies only under certain conditions; the user needs to validate the shape of submitted data (required, length, format) before it is persisted in CakePHP. Keywords: cakephp, validation, validator, application-rules, rules-checker, input.
20 other projects use a version of this.
Adopted by
Most recently taken up by
- thistleknot/skillstheir own version, first seen Nov 8, 2026
- GoogleCloudPlatform/cloud-solutionstheir own version, first seen Nov 8, 2026
- LeanMeanCleanApps/CleanModelContextProtocoltheir own version, first seen Nov 8, 2026
- ruujOnChain/HedgeFund-Skillstheir own version, first seen Nov 8, 2026
- honeydew-ai/honeydew-ai-coding-agents-pluginstheir own version, first seen Nov 1, 2026
- aibtcdev/skillstheir own version, first seen Oct 26, 2026
Used with
Projects with it also use testing.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
NVIDIASkilltesting
Run Python and Rust tests for physicsnemo-curator using uv + pytest with coverage reporting via pytest-cov, and cargo-nextest for Rust tests. Includes benchmark workflows with pytest-benchmark and criterion.
Also in 3 projects that use this
Other versions20 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 20
- openai/codex-security★ 11ksame name
- openai/plugins★ 7.8ksame name
- GoogleCloudPlatform/cloud-solutions★ 139same name
- richard-kim-79/archora-skills★ 49same name
- honeydew-ai/honeydew-ai-coding-agents-plugins★ 43same name
- wolverin0/claude-skills★ 41same name
- loocor/mcpmate★ 35same name
- ruujOnChain/HedgeFund-Skills★ 17same name
- aibtcdev/skills★ 11same name
- jkaninda/okapi-skills★ 3same name
10 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository119 other files it gives its agents.
- strategy-bitrix-d7-incrementalSkill
- strategy-explicit-over-magicSkill
- strategy-framework-conventionsSkill
- strategy-legacy-safe-editsSkill
- strategy-minimal-diffSkill
- strategy-no-untested-refactorSkill
- strategy-preserve-public-apiSkill
- strategy-readonly-immutabilitySkill
- strategy-security-firstSkill
- strategy-test-drivenSkill
- openapiSkill
- paginationSkill
- rest-designSkill
- versioningSkill
- cqrsSkill
- dependency-inversionSkill
- hexagonalSkill
- repository-patternSkill
- service-layerSkill
- bitrixSkill
- findings-reportSkill
- laravelSkill
- performanceSkill
- phpSkill
- project-analysisSkill
- refactoringSkill
- roi-prioritizationSkill
- securitySkill
- stack-detectionSkill
- cache-layersSkill
- component-engineSkill
- d7-eventsSkill
- d7-loaderSkill
- d7-orm-queriesSkill
- iblock-elementsSkill
- kernel-main-moduleSkill
- localizationSkill
- controllersSkill
- ormSkill
- controllersSkill
- query-builderSkill
- routingSkill
- autoload-psr4Skill
- dependency-managementSkill
- scriptsSkill
- connection-poolingSkill
- mysql-indexingSkill
- redisSkill
- transactionsSkill
- ci-github-actionsSkill
- deployment-strategiesSkill
- docker-phpSkill
- env-configSkill
- associationsSkill
- entities-mappingSkill
- orm-basicsSkill
- entity-apiSkill
- module-developmentSkill
- routing-controllersSkill
- formsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 20 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 66
Do not model "may this user perform this action" as a validation rule.
- Distinctive: line 67
Do not use this skill for Symfony Validator, Laravel validation, or Respect/Validation.
- Very specific: line 88
Treat a falsey save() return (or a marshalled entity with getErrors()) as the signal that validation failed, and surface those messages …
- Very specific: line 91
Use requirePresence('field') to require the key to exist in the data, and notEmptyString('field') (or the typed notEmpty variant) to reject …
“Common” is measured: kept by at least 6 in 10 of the 20 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- generated: do not edit — source: knowledge/atoms/cakephp/validation/ --><!-- schema: atomVersion=3 skillVersion=2 graphVersion=1 --><!-- compile: @php-skills/compiler v1.0.0 (deterministic build) -->CakePHP Validation
When to use
- The user needs rules that depend on the database, such as uniqueness or foreign-key existence, checked before a save commits.
- The user wants a custom validation rule, a named validation set, or a rule that applies only under certain conditions.
- The user needs to validate the shape of submitted data (required, length, format) before it is persisted in CakePHP.
When NOT to use
- Do not model "may this user perform this action" as a validation rule; that is an authorization concern handled by policies, not the Validator.
- Do not use this skill for Symfony Validator, Laravel validation, or Respect/Validation; the Validator and RulesChecker API is CakePHP specific.
Core guidance
- Enforce uniqueness with isUnique in buildRules, not the Validator — Add
$rules->add($rules->isUnique(['email']))inbuildRules()for uniqueness, rather than trying to check it in the shape Validator. - Validate shape with a Validator, integrity with application rules — Put format and presence checks (required, email, length) in
validationDefault()where they run during marshalling; put database-dependent checks (unique, exists) inbuildRules()where they run at save time.
Quick recipe
- In the Table's
validationDefault(Validator $validator), chain rules likerequirePresence('email'),notEmptyString('email'), andemail('email'). (verify: Marshalling malformed data populates the entity's errors) - In
buildRules(RulesChecker $rules), add$rules->add($rules->isUnique(['email']))and any existsIn foreign-key checks, backed by matching database constraints. (verify: Saving a duplicate email fails with a rule error) - Marshal input with
patchEntity(), callsave(), and on a falsey result read$entity->getErrors()to display per-field messages. (verify: Valid data persists; invalid data returns messages and saves nothing)
Best practices
- Treat a falsey
save()return (or a marshalled entity withgetErrors()) as the signal that validation failed, and surface those messages instead of assuming success - Define alternate validation methods (e.g
- Use
requirePresence('field')to require the key to exist in the data, andnotEmptyString('field')(or the typed notEmpty variant) to reject blank values; combine them when a field must be both present and non-empty
Anti-patterns
| Anti-pattern | Why it fails | Do instead |
| Encoding permission checks as validation rules | Mixing authorization into validation hides access control in the model layer, where it is easy to forget and hard to audit. | Keep permission checks in authorization policies and reserve validation for data correctness. |
| Relying on client-side validation for correctness | Client validation is trivially bypassed with a direct request, so unchecked data reaches the database. | Enforce every rule server-side in the Table and use client validation only to improve the user experience. |
| Validating with manual checks in the controller | Controller-side checks drift from the model's rules, get duplicated per action, and are skipped by other save paths. | Declare the rules once in the Table's Validator/RulesChecker so every write path enforces them. |
See references/anti-patterns.md.
Common mistakes
- Confusing requirePresence with notEmpty — Adding only
requirePresencestill lets an empty string through, and adding onlynotEmptystill lets a missing key through. Fix: CombinerequirePresenceand the appropriatenotEmpty*rule when a field must be both present and filled. - Ignoring the save return value hides validation failures — Calling
save()and ignoring its return lets a validation or rule failure pass silently, so nothing is persisted but the code continues. Fix: Branch on the boolean result (or usesaveOrFailwhere an exception is appropriate) and readgetErrors()on failure. - Uniqueness placed in the Validator never runs at save — A uniqueness check written into the shape Validator does not have database access at marshalling time and cannot reliably enforce uniqueness. Fix: Move uniqueness to
buildRules()withisUnique, backed by a database unique index.
Version notes
- CakePHP 5 tightens Validator and rule signatures — CakePHP 5 (PHP 8.1+) uses stricter parameter and return types on the Validator and
RulesChecker methods, so custom rules and
validationDefault()overrides should adopt the typed signatures used in the 5.x API.
Security
- Always validate on the server; never trust client checks — Define the authoritative rules in the Table's Validator and RulesChecker and run them on every write path; treat client-side or JavaScript validation as UX only, and pair uniqueness rules with real database constraints.
Testing
- Activation and decision behavior are verified in
eval/scenarios/cakephp/validation.yaml.
Additional resources
- references/anti-patterns.md
- references/core.md
- references/examples.md
- references/pitfalls.md
- references/recipes.md
- references/version-differences.md
Knowledge graph
Related: cakephp/controllers, cakephp/orm, php/typed-properties
<!-- graph-fragment: graph/fragments/cakephp/validation.yaml -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

