Download the PHP package craftcms/laravel-ruleset-validation without Composer

On this page you can find all versions of the php package craftcms/laravel-ruleset-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-ruleset-validation

Laravel Ruleset Validation

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Move validation out of controllers, form requests, and ad hoc validators into reusable ruleset objects.

This package provides a Ruleset base class that can validate either:

That makes it useful for DTOs, actions, domain objects, and controllers that want FormRequest-style validation without requiring a dedicated FormRequest subclass for every workflow.

Installation

Install the package via Composer:

The package uses Laravel package auto-discovery, so no manual service provider registration is required.

If You Already Know Form Requests

For request-backed validation, this package intentionally follows Laravel's FormRequest validation model as closely as possible.

Read the Laravel documentation for the validation lifecycle, authorization, hooks, validated input, redirects, error bags, and Precognition:

Laravel Form Request Validation

Laravel Working With Validated Input

If you know how to write a FormRequest, you already know how to write a Ruleset.

What This Package Adds

The main difference from FormRequest is not the validation API, but where the validation logic can live.

1. You can attach a ruleset to any object

Create a class that implements ValidatesWithRuleset, add the HasRuleset trait, then point it at a ruleset.

Then define the ruleset:

Validate the object anywhere in your application:

You can also validate only a subset of attributes:

And if you need a non-throwing flow for object-backed validation:

2. You can inject a ruleset directly for a request

If you want FormRequest behavior without a FormRequest subclass, type-hint the ruleset in your controller action and let Laravel resolve it.

If you need to construct one manually, you can instantiate the ruleset directly:

3. You can reuse one ruleset across multiple contexts via scenarios

Rulesets include a lightweight scenario API that FormRequest does not provide.

If you only want to switch scenarios for one operation, use withScenario(). The previous scenario is restored after the callback returns or throws.

Available helpers:

When injecting a ruleset into a controller, you can also set the scenario with a parameter attribute:

Form Request Compatibility Notes

When a ruleset is validating an Illuminate\Http\Request, the Laravel docs above apply directly to the following features:

This package mirrors that behavior, with a few small differences:

Choosing A Ruleset For An Object

You can associate a validatable object with a ruleset in two ways.

Using the #[Ruleset] attribute

Using a ruleset() method

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-ruleset-validation with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
illuminate/contracts Version ^13.0
illuminate/support Version ^13.0
illuminate/validation Version ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package craftcms/laravel-ruleset-validation contains the following files

Loading the files please wait ...