Download the PHP package aegisora/date-format-rule without Composer

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

Aegisora Date Format Rule

Latest Version Total Downloads PHPStan Badge

Date Format Rule provides a simple, rule-based date/time format validation implementation for the Aegisora ecosystem.

It is built on top of aegisora/rule-contract and follows its strict validation architecture, ensuring consistent and predictable behavior across applications.

This rule is useful for validating user input, form fields, birth dates, appointment times, API request parameters, imported data, and any other string that must conform to a specific date/time format.


๐Ÿ“‘ Table of Contents


โœจ Features


๐Ÿ“ฆ Installation


๐Ÿš€ Core Concept

This package implements a single validation rule:

Under the hood it wraps the common โ€” and easy to get wrong โ€” boilerplate:

into a reusable rule that reports its outcome through a Result object instead of a raw boolean.


๐Ÿ—๏ธ Basic Usage


โœ… Valid vs Invalid

The rule passes when the string is a real date/time that renders back exactly as the input under the configured format, and fails otherwise.

Dates

Strict formatting

Times and combined formats


๐Ÿงช Validation Result

If the string is a valid date/time matching the format, the rule returns a valid result.

$result->isValid(); // true

If the string does not match the format, the rule returns an invalid result.

If the context value is not a string, the rule throws:

Aegisora\RuleContract\Exceptions\InvalidRuleContextException

If the configured format is an empty string, the rule throws:

Aegisora\RuleContract\Exceptions\InvalidRuleContextException


๐ŸŒ Time Zones

An optional DateTimeZone can be passed as the second argument. It is used while parsing the value, which matters for formats that carry time information.

If the format itself carries a time zone (e, T, P, O), that value takes precedence and the argument is ignored.


๐Ÿ”— Guardian Usage

This rule can be used together with aegisora/guardian to build fluent validation pipelines.

If the value does not match the format, Guardian throws the provided domain exception.


๐Ÿงญ Real-World Examples

Date Format Rule is useful for enforcing date/time constraints before values are persisted or processed.

Examples


๐Ÿงฉ Constructor & API

new DateFormatRule($format);

new DateFormatRule($format, $timeZone);

(new DateFormatRule($format))->validate($context);


๐Ÿ›๏ธ Architecture

This package relies on aegisora/rule-contract.

Flow:

  1. validate() is called
  2. Context is passed in
  3. The configured format is checked; an empty format raises InvalidRuleContextException
  4. The string value is extracted from context (non-strings raise InvalidRuleContextException)
  5. The value is parsed with DateTimeImmutable::createFromFormat(), checked against getLastErrors() for overflow/out-of-range warnings, and round-tripped back through the format to reject non-canonical input
  6. Result is returned โ€” valid on a strict match, invalid with the date_format_rule code otherwise

All logic is safely handled by Rule contract.


โš–๏ธ 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 date-format-rule with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
aegisora/rule-contract 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/date-format-rule contains the following files

Loading the files please wait ...