{"id":19029975,"url":"https://github.com/padosoft/laravel-validable","last_synced_at":"2025-07-01T04:34:49.708Z","repository":{"id":32435432,"uuid":"133529673","full_name":"padosoft/laravel-validable","owner":"padosoft","description":"Laravel trait to auto-validates a model on save. ","archived":false,"fork":false,"pushed_at":"2025-04-04T15:28:53.000Z","size":431,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-01T07:36:38.761Z","etag":null,"topics":["laravel","laravel-package","model","trait","validation","validator"],"latest_commit_sha":null,"homepage":null,"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/padosoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2018-05-15T14:39:05.000Z","updated_at":"2025-04-04T15:28:58.000Z","dependencies_parsed_at":"2024-05-20T11:41:31.352Z","dependency_job_id":"7dbe2322-c923-4d8e-956f-252bb166c926","html_url":"https://github.com/padosoft/laravel-validable","commit_stats":{"total_commits":27,"total_committers":5,"mean_commits":5.4,"dds":0.5555555555555556,"last_synced_commit":"87472dce50bb939d03fdbfe805af7919383ffdad"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/padosoft/laravel-validable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Flaravel-validable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Flaravel-validable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Flaravel-validable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Flaravel-validable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/padosoft","download_url":"https://codeload.github.com/padosoft/laravel-validable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Flaravel-validable/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262898691,"owners_count":23381611,"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":["laravel","laravel-package","model","trait","validation","validator"],"created_at":"2024-11-08T21:16:00.990Z","updated_at":"2025-07-01T04:34:49.686Z","avatar_url":"https://github.com/padosoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trait to activate validation when saving Eloquent Model\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/padosoft/laravel-validable.svg?style=flat-square)](https://packagist.org/packages/padosoft/laravel-validable)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![CircleCI](https://circleci.com/gh/padosoft/laravel-validable/tree/master.svg?style=svg)](https://circleci.com/gh/padosoft/laravel-validable/tree/master)\n[![Quality Score](https://img.shields.io/scrutinizer/g/padosoft/laravel-validable.svg?style=flat-square)](https://scrutinizer-ci.com/g/padosoft/laravel-validable)\n[![Total Downloads](https://img.shields.io/packagist/dt/padosoft/laravel-validable.svg?style=flat-square)](https://packagist.org/packages/padosoft/laravel-validable)\n\nThis package provides a trait that will automatic handlind upload when saving/updating/deleting any Eloquent model with upload form request.\n\n##Requires\n  \n- php: \u003e=7.0.0\n- illuminate/database: ^5.0|^6.0|^7.0|^8.0|^9.0|^10.0\n- illuminate/support: ^5.0|^6.0|^7.0|^8.0|^9.0|^10.0\n- illuminate/validation: ^5.0|^6.0|^7.0|^8.0|^9.0|^10.0\n  \n## Installation\n\nYou can install the package via composer:\n``` bash\n$ composer require padosoft/laravel-validable\n```\n\n## Usage\n\nYour Eloquent models should use the `Padosoft\\Laravel\\Validable\\Validable` trait.\n\nYou must define `protected static $rules`  array of rules in your model. \nYou can define `protected static $messages`  array of custom messages in your model. \n\nHere's an example of how to implement the trait;\n\n```php\n\u003c?php\n\nnamespace App;\n\nuse Padosoft\\Laravel\\Validable\\Validable;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass YourEloquentModel extends Model\n{\n    use Validable;\n    protected static $rules = [\n            'name'=\u003e'required|max:10',\n            'order'=\u003e'sometimes|integer|max:10',\n        ];\n    \n        protected static $messages = [\n            'name.required'=\u003e'obbligatorio'\n        ];\n}\n```\nYou can write specific validation for only update method\n```php\nclass YourEloquentModel extends Model\n{\n    use Validable;\n    protected static $rules = [\n            'name'=\u003e'required|max:10|unique:table,field',\n            'order'=\u003e'sometimes|integer|max:10',\n        ];\n    protected static $updating_rules = [\n                'name'=\u003e'required|max:10|unique:table,field,[id]',\n                'order'=\u003e'sometimes|integer|max:10',\n            ];\n        protected static $messages = [\n            'name.required'=\u003e'obbligatorio'\n        ];\n}\n```\n**Note:** [id] will be overwritten at runtime with the model property.\n\nYou can check if your model is saved like this:\n\n```php\n$model = new YourEloquentModel;\n$model-\u003ename='test';\nif (!$model-\u003esave()){\n    $erros=$model-\u003egetErrors();\n}\n```\nYou can get a model validation rules:\n\n```php\n$rules=YourEloquentModel::getRules();\n```\n\nFor all method available see the Validable Trait.\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email instead of using the issue tracker.\n\n## Credits\nInspired by https://github.com/JeffreyWay/Laravel-Model-Validation\n- [Lorenzo Padovani](https://github.com/lopadova)\n- [Leonardo Padovani](https://github.com/leopado)\n- [All Contributors](../../contributors)\n\n## About Padosoft\nPadosoft (https://www.padosoft.com) is a software house based in Florence, Italy. Specialized in E-commerce and web sites.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpadosoft%2Flaravel-validable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpadosoft%2Flaravel-validable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpadosoft%2Flaravel-validable/lists"}