Download the PHP package aegisora/emptiness-rule-guardian without Composer

On this page you can find all versions of the php package aegisora/emptiness-rule-guardian. 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 emptiness-rule-guardian

Aegisora Emptiness Rule Guardian

Latest Version Total Downloads PHPStan Badge

Emptiness Rule Guardian provides a simple shortcut for emptiness validation using aegisora/guardian and aegisora/emptiness-rule.

It is designed for cases where you want to quickly check whether a value is empty or is not empty, without manually building an EmptyRule / NotEmptyRule and a validation pipeline by hand.

This package is built on top of:


โœจ Features


๐Ÿ“ฆ Installation


๐Ÿš€ Core Concept

This package wraps the common emptiness validation flow:

into a dedicated shortcut class:

Instead of manually creating an EmptyRule / NotEmptyRule and passing it to Guardian, you can use EmptinessRuleGuardian directly.


๐Ÿ—๏ธ Basic Usage

checkEmpty() passes when $value is empty, and fails otherwise.

checkNotEmpty() passes when $value is not empty, and fails otherwise.


โœ… How the emptiness check works

A value is considered empty when it is null, an empty string, an empty array or an empty countable object. Every other value โ€” including 0, 0.0, false and non-countable objects โ€” is considered not empty:

checkNotEmpty() is the exact inverse โ€” it passes for every value listed above as fails and fails for every value listed as passes.

โš ๏ธ A resource cannot be evaluated for emptiness. Passing a resource raises a GuardianExecutingRuleException (see below) instead of a validation result.


๐Ÿงฉ Usage with Custom Exception

You may provide your own exception for validation failure. It must be the last argument.

If the value is empty, the provided exception will be thrown instead of GuardianValidationException.

This is useful when validation errors should have domain-specific meaning.


๐Ÿงช Example in Application Service


๐Ÿšจ Exceptions

The package raises validation-related exceptions, all delegated to Guardian (the outcome of running the rule):

GuardianValidationException

Thrown when validation fails and no custom exception is provided.

The rule code for a failed checkEmpty() is empty_rule, and for a failed checkNotEmpty() it is not_empty_rule.

Custom exception

When a custom exception is passed as the last argument, it is thrown instead of GuardianValidationException on validation failure.

GuardianExecutingRuleException

Thrown when the underlying rule fails to execute (raises a RuleException during validation), as opposed to simply reporting an invalid result.

Emptiness cannot be determined for a resource, so passing a resource surfaces this exception instead of a validation result:


๐Ÿงฉ API

EmptinessRuleGuardian::checkEmpty()

Validates that $value is empty.

EmptinessRuleGuardian::checkNotEmpty()

Validates that $value is not empty.

Arguments (both methods):

The methods return void. They communicate results through exceptions only โ€” they return nothing on success and throw on failure:


๐Ÿ›๏ธ Architecture

This package is a small shortcut layer over the Aegisora validation pipeline.

Flow:

  1. EmptinessRuleGuardian::checkEmpty() / checkNotEmpty() is called with a value and an optional exception
  2. An EmptyRule / NotEmptyRule is created (create())
  3. Guardian executes the rule against the value
  4. If the check passes, execution continues normally
  5. If the check fails, the custom exception or GuardianValidationException is thrown
  6. If the rule could not be executed, GuardianExecutingRuleException is thrown

Internal flow:


๐Ÿ”— Related Packages


โš–๏ธ License

This package is open-source and licensed under the MIT License. See the LICENSE for details.


๐ŸŒฑ Contributing

Contributions are welcome and greatly appreciated!. See the CONTRIBUTING for details.


๐ŸŒŸ Support

If you find this project useful, please consider giving it a star on GitHub!

It helps the project grow and motivates further development.


All versions of emptiness-rule-guardian with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
aegisora/guardian Version ^1.0
aegisora/emptiness-rule Version ^1.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 aegisora/emptiness-rule-guardian contains the following files

Loading the files please wait ...