kakaprodo / custom-data
A Laravel package that wraps function arguments together into a single CustomData class allowing separate processing and validation for each argument.
Installs: 3 663
Dependents: 5
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
- laravel/framework: >=7.0
- dev-develop
- v2.3.5
- v2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.1
- 2.2.0
- v2.1.3
- v2.1.2
- 2.1.1
- v2.1.0
- v2.0.0
- v1.9.9
- 1.9.8
- v1.9.7
- v1.9.6
- v1.9.5
- v1.9.4
- v1.9.3
- v1.9.2
- v1.9.1
- v1.9.0
- v1.8.5
- v1.8.2
- v1.8.1
- v1.8
- v1.7
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6
- v1.5
- v1.2.0
- v1.1
- v1
- dev-promesse/add-property-props-helper
- dev-promesse/property-grouping
- dev-main
This package is auto-updated.
Last update: 2025-05-29 09:06:33 UTC
README
Official Documentation
A Laravel package that wraps function arguments together into a single CustomData class allowing separate processing and validation for each argument.
class CreateUserData extends CustomData { protected function expectedProperties(): array { return [ 'name' => $this->dataType()->string(), 'email' => $this->dataType()->string(), 'password' => $this->dataType()->string(), 'age?' => $this->dataType()->string(), 'sexe' => $this->dataType()->inArray(['M','F']) ]; } }
And then call it this way:
CreateUserData::make([ 'name' => 'kakaprodo', 'email' => 'example@gmail.com', 'password' => 'is_unique_pass', 'sexe' => 'M' ]);
And if you like to decouple your code with small classes called Action , then you are at the right place:
class CreateUserAction extends CustomActionBuilder { public function handle(CreateUserData $data) { return $data->onlyValidated(); } }
And then we call our action this way:
CreateUserAction::process([ 'name' => 'kakaprodo', 'email' => 'example@gmail.com', 'password' => 'is_unique_pass', 'sexe' => 'M' ]);
Features
- Combine several function arguments into one class called CustomData
- Validate each argument a little bit the way TypeScript does it in Javascript
- Support the definition of Laravel FormValidation rules
- Support Action classes in which CustomData can be injected
- Support The Ability to Queue Action class
- Support helper command to generate Action and CustomData classes
You can find here the Official Documentation