{"id":24016366,"url":"https://github.com/decodelabs/lucid","last_synced_at":"2025-04-15T14:07:38.879Z","repository":{"id":58816232,"uuid":"531558940","full_name":"decodelabs/lucid","owner":"decodelabs","description":"Flexible and expansive sanitisation and validation framework for PHP","archived":false,"fork":false,"pushed_at":"2025-04-14T08:48:36.000Z","size":137,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-14T09:46:09.287Z","etag":null,"topics":["php","sanitization","validation"],"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/decodelabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-09-01T14:37:51.000Z","updated_at":"2025-04-14T08:48:40.000Z","dependencies_parsed_at":"2023-02-15T07:46:09.163Z","dependency_job_id":"cd5f7ca7-c804-4a59-a099-f45f9ed624ac","html_url":"https://github.com/decodelabs/lucid","commit_stats":{"total_commits":64,"total_committers":1,"mean_commits":64.0,"dds":0.0,"last_synced_commit":"ddf7ef8b25e1b2160df51c6873d5878527ce90b9"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Flucid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Flucid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Flucid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Flucid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decodelabs","download_url":"https://codeload.github.com/decodelabs/lucid/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860094,"owners_count":21173339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["php","sanitization","validation"],"created_at":"2025-01-08T08:49:06.706Z","updated_at":"2025-04-15T14:07:38.873Z","avatar_url":"https://github.com/decodelabs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lucid\n\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/lucid?style=flat)](https://packagist.org/packages/decodelabs/lucid)\n[![Latest Version](https://img.shields.io/packagist/v/decodelabs/lucid.svg?style=flat)](https://packagist.org/packages/decodelabs/lucid)\n[![Total Downloads](https://img.shields.io/packagist/dt/decodelabs/lucid.svg?style=flat)](https://packagist.org/packages/decodelabs/lucid)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/decodelabs/lucid/integrate.yml?branch=develop)](https://github.com/decodelabs/lucid/actions/workflows/integrate.yml)\n[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true\u0026style=flat)](https://github.com/phpstan/phpstan)\n[![License](https://img.shields.io/packagist/l/decodelabs/lucid?style=flat)](https://packagist.org/packages/decodelabs/lucid)\n\n### Flexible and expansive sanitisation and validation framework for PHP\n\nLucid provides a unified single-value sanitisation and validation structure for making sure your input makes sense.\n\n---\n\n\n## Installation\n\nInstall the library via composer:\n\n```bash\ncomposer require decodelabs/lucid\n```\n\n## Usage\n\nDirect value sanitisation can be achieved quickly and painlessly:\n\n```php\nuse DecodeLabs\\Lucid;\n\n// This ensures the value is a string\n$myString = Lucid::cast('string', 'This is a string');\n\n// This is nullable\n$notAString = Lucid::cast('?string', null);\n\n// These are constraints - throws an exception\n$myString = Lucid::cast('string', 'My very long piece of text', [\n    'maxLength' =\u003e 10,\n    'maxWords' =\u003e 4\n]);\n\n// Creates an instance of Carbon (DateTime)\n$myDate = Lucid::cast('date','tomorrow', [\n    'min' =\u003e 'yesterday',\n    'max' =\u003e '+3 days'\n]);\n```\n\nIf you need more fine grained control of the responses to constraints, use \u003ccode\u003evalidate()\u003c/code\u003e:\n\n```php\n$result = Lucid::validate('int', 'potato', [\n    'min' =\u003e 4\n]);\n\nif(!$result-\u003eisValid()) {\n    // Do something with the potato\n\n    foreach($result-\u003egetErrors() as $error) {\n        echo $error-\u003egetMessage();\n    }\n}\n```\n\nOr conversely if you just need a yes or no answer, use \u003ccode\u003eis()\u003c/code\u003e:\n\n```php\nif(!Lucid::is('float', 'not a number')) {\n    // do something\n}\n```\n\n### Importing\n\nLucid uses [Veneer](https://github.com/decodelabs/veneer) to provide a unified frontage under \u003ccode\u003eDecodeLabs\\Lucid\u003c/code\u003e.\nYou can access all the primary functionality via this static frontage without compromising testing and dependency injection.\n\n\n## Custom processors\n\nLucid uses [Archetype](https://github.com/decodelabs/archetype) to load both \u003ccode\u003eProcessors\u003c/code\u003e and \u003ccode\u003eConstraints\u003c/code\u003e - implement your own custom classes within \u003ccode\u003eDecodeLabs\\Lucid\\Processor\u003c/code\u003e or \u003ccode\u003eDecodeLabs\\Lucid\\Constraint\u003c/code\u003e namespaces, or create your own Archetype \u003ccode\u003eResolver\u003c/code\u003e to load them from elsewhere.\n\nPlease see the selection of existing implementations for details on how to build your own custom classes.\n\n\n## Provider interfaces\n\nLucid builds on a sub-package, [Lucid Support](https://github.com/decodelabs/lucid-support) which makes available a set of \u003ccode\u003eProvider\u003c/code\u003e interfaces to enable embedded implementations of the Sanitizer structure.\n\nPlease see the readme in [Lucid Support](https://github.com/decodelabs/lucid-support) for integrating Lucid into your own libraries.\n\n\n## Licensing\nLucid is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodelabs%2Flucid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecodelabs%2Flucid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodelabs%2Flucid/lists"}