{"id":29774893,"url":"https://github.com/neimee8/validator-php","last_synced_at":"2026-05-18T02:35:50.104Z","repository":{"id":301259090,"uuid":"1007905784","full_name":"neimee8/validator-php","owner":"neimee8","description":"Work-in-progress PHP validation library with flexible rules, multiple agents, and structured error reporting.","archived":false,"fork":false,"pushed_at":"2025-08-03T17:46:52.000Z","size":186,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-03T19:31:43.139Z","etag":null,"topics":["composer","library","main-repo","mit","oop","php","reflection-api","validation","validator-php","wip"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neimee8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-24T18:03:48.000Z","updated_at":"2025-08-03T17:46:56.000Z","dependencies_parsed_at":"2025-08-03T19:13:01.381Z","dependency_job_id":"50f4fc39-0917-4c59-85d0-76e14276f0b9","html_url":"https://github.com/neimee8/validator-php","commit_stats":null,"previous_names":["neimee8/validator-php"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/neimee8/validator-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neimee8%2Fvalidator-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neimee8%2Fvalidator-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neimee8%2Fvalidator-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neimee8%2Fvalidator-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neimee8","download_url":"https://codeload.github.com/neimee8/validator-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neimee8%2Fvalidator-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33162684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","library","main-repo","mit","oop","php","reflection-api","validation","validator-php","wip"],"created_at":"2025-07-27T09:00:58.582Z","updated_at":"2026-05-18T02:35:50.097Z","avatar_url":"https://github.com/neimee8.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚧 This project is a work in progress\n\nWhile the main functionality is implemented and appears to work, the code hasn't been refactored yet, and there are no tests or documentation.\nExpect bugs, especially in edge cases.\n\n## 🛠️ Planned \u0026 Implemented\n\n### ValidationNode\n\n```php\nValidationNode(\n    array|self|null $node = null,\n    ?string $rule = null,\n    ?array $params = null,\n    ?ValidationMode $validation_mode = null\n);\n```\n\n#### 📌 Purpose\nRepresents a single validation rule with its parameters.\n\n#### 🛠️ Construction formats\nYou can instantiate a `ValidationNode` using:\n\n1. Associative format:\n  ```php\n  new ValidationNode(\n      node: [\n          'rule' =\u003e 'value_in',\n          'params' =\u003e [\n              'haystack' =\u003e [1, 2, 3]\n          ]\n      ]\n  );\n  ```\n2. Indexed format:\n  ```php\n  new ValidationNode(node: ['equals', [[1, 2, 3]]]);\n  ```\n3. Direct parameters:\n  ```php\n  new ValidationNode(rule: 'equals', params: [[1, 2, 3]]);\n  ```\n4. Validation mode\n  ```php\n  new ValidationNode(..., validation_mode: ValidationNode::DISALLOW_INCOMPATIBLE_VALUES);\n  ```\n  `validation_mode` controls behavior when the validated value is incompatible with the rule's expected type:\n  * `DISALLOW_INCOMPATIBLE_VALUES` – throws an exception on incompatible types (default)\n  * `ALLOW_INCOMPATIBLE_VALUES` – silently returns `false`\n\n  These modes are available on all `ValidationAgent` subclasses.\n\n#### ⚙️ Configuration methods\nYou can also configure a ValidationNode after instantiation:\n\n```php\n$node = new ValidationNode();\n$node -\u003e setNode([\n    'rule' =\u003e 'value_in',\n    'params' =\u003e [\n        'haystack' =\u003e [1, 2, 3]\n    ]\n]);\n$node -\u003e setRule('value_in');\n$node -\u003e setParams(['haystack' =\u003e [1, 2, 3]]);\n```\n\n#### ✅ Validation\nTo validate a value:\n```php\n$node -\u003e validate($value);\n```\nBehavior:\n  * Returns `bool` by default.\n  * To retrieve validation result explicitly:\n  ```php\n  $node -\u003e getResult();\n  ```\n  * To retrieve a detailed report:\n  ```php\n  $node -\u003e getReport();\n  ```\n  * To get a report directly from `validate()`:\n  ```php\n  $node -\u003e validate($value, return_report: true);\n  ```\n\n---\n\n### ValidationExpression\n\n```php\nValidationExpression(\n    array|self|null $expression = null,\n    string $logic = 'all',\n    ?array $operands = null,\n    ?bool $invert = null,\n    ?ValidationMode $validation_mode = null\n);\n```\n\n#### 📌 Purpose\nCombines multiple `ValidationNode` or `ValidationExpression` instances under a logical operator: `all`, `any`, `one`, `none`.\n\n#### 🛠️ Construction formats\nYou can instantiate a `ValidationExpression` using:\n\n1. Associative format:\n  ```php\n  new ValidationExpression(\n      expression: [\n          'logic' =\u003e 'all',\n          'operands' =\u003e [\n              ['rule' =\u003e 'type', 'params' =\u003e ['type' =\u003e 'string']],\n              ['logic' =\u003e 'any', 'operands' =\u003e [\n                  ['rule' =\u003e 'str_min_len', 'params' =\u003e ['size' =\u003e 10]],\n                  ['rule' =\u003e 'str_len', 'params' =\u003e ['size' =\u003e 0]],\n              ]],\n          ],\n          'invert' =\u003e true\n      ]\n  );\n  ```\n2. Indexed format:\n  ```php\n  new ValidationExpression(\n      expression: [\n          'all',\n          [\n              ['type', ['string']],\n              ['any', [\n                  ['str_min_len', [10]],\n                  ['str_len', [0]],\n              ]],\n          ],\n          true\n      ]\n  );\n  ```\n3. Direct parameters:\n  ```php\n  new ValidationExpression(\n      logic: 'all',\n      operands: [\n          ['type', ['string']],\n          ['any', [\n              ['str_min_len', [10]],\n              ['str_len', [0]],\n          ]],\n      ],\n      invert: true,\n      valdiation_mode: ValidationExpression::ALLOW_INCOMPATIBLE_VALUES\n  );\n  ```\n  `invert` is optional and defaults to `false`.\n\n  `validation_mode` behaves the same as in `ValidationNode`.\n\n#### 🔧 Operand types\nEach operand can be:\n* ValidationNode (array or instance)\n* ValidationExpression (array or instance)\n\n```php\n[\n    'all',\n    [\n        new ValidationNode(['rule' =\u003e 'str_contains', 'params' =\u003e ['needle' =\u003e 'foo']])\n    ]\n]\n```\n\n#### ⚙️ Configuration methods\n```php\n$expr -\u003e setExpression([...]);\n$expr -\u003e setLogic('any');\n$expr -\u003e setOperands([...]);\n$expr -\u003e addOperands([...]);\n$expr -\u003e addOperand(...);\n$expr -\u003e setInvertion(true);\n```\n\n#### ✅ Validation\n```php\n$expr -\u003e validate($value);\n```\nAdditional parameters:\n* `return_report` (default: `false`). Returns a full report if set to `true`.\n* `collect_detailed` (default: `true`). Controls whether reports from individual operands (nodes or nested expressions) are collected. If set to `false`, avoids recursive report aggregation to improve performance.\n* `force_validation_mode` (default: `true`). Temporarily overrides the `validation_mode` of all nested operands for a single validation call.\n\n---\n\n### ValidationEntry\n\n```php\nValidationEntry(\n    array|self|null $entry = null,\n    mixed $value = EmptyMarker::VALUE,\n    array|ValidationNode|ValidationExpression|null $operand = null,\n    ?ValidationMode $validation_mode = null\n);\n```\n\n#### 📌 Purpose\nEncapsulates a value with its corresponding operand (`ValidationNode` or `ValidationExpression`) and delegates validation logic accordingly.\n\n#### 🛠️ Construction formats\nYou can instantiate a `ValidationEntry` using:\n\n1. Associative format\n  ```php\n  new ValidationEntry(\n      entry: [\n          'value' =\u003e 'some string',\n          'operand' =\u003e [\n              'rule' =\u003e 'type',\n              'params' =\u003e ['type' =\u003e 'string']\n          ]\n      ]\n  );\n  ```\n2. Indexed format\n  ```php\n  new ValidationEntry(\n      entry: [\n          'some string',\n          ['type', ['string']]\n      ]\n  );\n  ```\n3. Direct parameters\n  ```php\n  new ValidationEntry(\n      value: 'some string',\n      operand: ['type', ['string']],\n      validation_mode: ValidationEntry::ALLOW_INCOMPATIBLE_VALUES\n  );\n  ```\n\n#### 🔧 Operand types\nEach operand can be:\n* ValidationNode (array or instance)\n* ValidationExpression (array or instance)\n\n#### ⚙️ Configuration methods\n```php\n$entry -\u003e setEntry([...])\n$entry -\u003e setValue(...);\n$entry -\u003e setOperand(...);\n```\n\n#### ✅ Validation\n```php\n$entry -\u003e validate(\n    return_report: false,\n    collect_detailed: true,\n    force_validation_mode: true\n);\n```\n\nBehavior:\n* Uses the `value` stored in the entry.\n* Delegates validation to the associated operand.\n* Supports all arguments that `ValidationExpression::validate()` supports (excluding `value`):\n  * return_report\n  * collect_detailed\n  * force_validation_mode\n\n---\n\n### ValidationMap\n\n```php\nValidationMap(\n    array|self|null $map = null,\n    ?ValidationMode $validation_mode = null\n);\n```\n\n#### 📌 Purpose\nRepresents a collection of validation entries, each optionally identified by a custom key. Enables batch validation of multiple values against their corresponding validation logic.\n\n#### 🛠️ Construction formats\nYou can instantiate a `ValidationMap` using:\n\n1. Associative format (`ID` specified):\n  ```php\n  new ValidationMap([\n      'email' =\u003e [\n          'value' =\u003e 'john.doe@gmail.com',\n          'operand' =\u003e ['rule' =\u003e 'str_email']\n      ],\n      'tags' =\u003e [\n          'value' =\u003e ['a', 'b'],\n          'operand' =\u003e ['rule' =\u003e 'arr_min_len', 'params' =\u003e [2]]\n      ]\n  ]);\n  ```\n2. Indexed format (`ID` omitted):\n  ```php\n  new ValidationMap([\n      [\n          'value' =\u003e 42,\n          'operand' =\u003e ['rule' =\u003e 'num_positive']],\n      [\n          'value' =\u003e 'abc',\n          'operand' =\u003e ['rule' =\u003e 'str_len', 'params' =\u003e [3]]\n      ]\n  ]);\n  ```\n  When `ID`s are omitted, entries are stored with numeric keys (`0`, `1`, `2`, ...).\n\n  Custom `ID`s are optional and used only for reference/reporting purposes.\n\n#### ⚙️ Configuration methods\n```php\n$map -\u003e setMap([...])\n$map -\u003e addEntry(...);\n$map -\u003e clearEntry('email');\n```\n\n#### ✅ Validation\n```php\n$map -\u003e validate(\n    return_report: false,\n    collect_detailed: true,\n    force_validation_mode: true\n);\n```\n\nBehavior:\n* Validation is performed independently for each `ValidationEntry` in the map.\n* The overall result of `validate()` is:\n    * `true` only if all entries pass (logical `AND` across all entries).\n    * `false` if any single entry fails.\n\n---\n\n### 📃 Planned\n* Flexible logic modes for `ValidationMap`\n    * Implement support for logical composition (`all`, `any`, `one`, `none`) similar to `ValidationExpression`\n    * Allow nested logic trees inside the map structure\n* Informative exception handling\n* Code refactoring\n* Unit testing\n* Full documentation\n* Generate `PHPDoc` with typed annotations for IDE autocompletion\n* Composer release\n\n## License\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nThis project is licensed under the MIT License – see the [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneimee8%2Fvalidator-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneimee8%2Fvalidator-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneimee8%2Fvalidator-php/lists"}