PHPackages                             christianberkman/codeigniter4-date-validation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. christianberkman/codeigniter4-date-validation

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

christianberkman/codeigniter4-date-validation
=============================================

Custom validation library for the CodeIgnitor4 framework to validate and compare dates

011PHP

Since Jul 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/christianberkman/codeigniter4-date-validation)[ Packagist](https://packagist.org/packages/christianberkman/codeigniter4-date-validation)[ RSS](/packages/christianberkman-codeigniter4-date-validation/feed)WikiDiscussions dev Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

codeigniter4-date-validation
============================

[](#codeigniter4-date-validation)

Custom validation library for the CodeIgniter4 framework to validate and compare dates.

To Do
-----

[](#to-do)

- Add rules:
- Use CodeIgniter4 coding standard library
- Create unit tests
- Use languae files for errors

Installation
------------

[](#installation)

### Installation via composer:

[](#installation-via-composer)

`composer require christianberkman/codeigniter4-date-validation`

If auto discovery in your CodeIgniter app is enabled, the library will be discovered automatically.

### Manual installation

[](#manual-installation)

Copy `src/DateValidation.php` to `app/ThirdParty`, adjust namespace and register in `app/Config/Validation.php`

Usage
-----

[](#usage)

The library offers rules for validating the value date to today or another field. All rules also validate the date so the built-in `valid_date` rule does not need to be called.

```
// any date before today's date
date_before_today[Y-m-d]

// any on or after a given field date
date_starting[date_arrival,Y-m-d]

// any date on Monday (1) or Wednesday (3)
date_on_dow[Y-m-d,1,3]

```

### Date Format

[](#date-format)

When comparing the value date to a field date, both dates are assumed to be in the same format. All format parameters are optional. If the format paremeter is specified, the dates will be creaed using `DateTime::createFromFormat`. If the format paremeter is omitted, the date is created using `strtotime()`. It is reccommended to always specify a format.

**Exception:** The format parameter is required for the `date_on_dow` rule, `'none'` can be specified if you wish to not specify any format: `'today' -> date_on_dow[none,1]`

### Time information

[](#time-information)

All time information is discarded, all times will be set to `00:00:00 UTC`.

Errors
------

[](#errors)

Errors are dynamically returned by each rule, e.g. `Date must be before last_available_date field`.

Available Rules
---------------

[](#available-rules)

RuleParametersDiscriptionExampledate\_before\_todayformatValidates if the value date is before todaydate\_before\_today\[Y-m-d\]date\_ending\_todayformatValidates if the value date is on or before todaydate\_ending\_today\[Y-m-d\]date\_starting\_todayformatValidates if the value date is on or after todaydate\_starting\_today\[Y-m-d\]date\_after\_todayformatValidates if the value date is after todaydate\_after\_todat\[Y-m-d\]date\_beforefield, formatValidates if the value date is before a field datedate\_before\[departure\_date,Y-m-d\]date\_endingfield, formatValidates if the value date is on or before a field datedate\_ending\[departure\_date,Y-m-d\]date\_startingfield, formatValidates if the value date is on or after a field datedate\_starting\[arrival\_date,Y-m-d\]date\_afterfield, formatValidates if the value date is after a field datedate\_after\[date\_of\_birth,Y-m-d\]date\_on\_dowformat, days of weekValidates if the value date is on a given day of week starting Monday (1-7)date\_on\_dow\[Y-m-d,1,2,3,4,5\]Full Example
------------

[](#full-example)

```
$data = [
    'arrival_date' => '2024-07-01',
    'excursion_date' => '2024-07-03',
    'depatrue_date' => '2024-07-10',
    'last_available_date' => '2027-08-09',
];

$rules = [
    // arrival needs to be at earliest tomorrow
    'arrival_date' => 'date_after_today',
    // excursion needs to be between (and not on) departure and arrival
    'excursion_date' => 'date_after[arrival_date,Y-m-d]|date_before[depatrue_date,Y-m-d]',
    // departure needs to be after (and not on) the arrival date and before (and not on) the last available date
    'departure_date' => 'date_after[arrival_date,Y-m-d]|date_before[last_available_Date]',
];

$validation = $this->validateData($data, $rules); // returns false
$errors = $this->validator->getErrors();
/**
 * Result:
 * 'departure_date' => 'Date must be before last_available_date field'
 */
```

###  Health Score

14

—

LowBetter than 1% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/de9c0d5604cc74a3dd6b93ddb0700df5fd85d4ba4532d8134c94ee123d86df3a?d=identicon)[christianberkman](/maintainers/christianberkman)

---

Top Contributors

[![christianberkman](https://avatars.githubusercontent.com/u/39840601?v=4)](https://github.com/christianberkman "christianberkman (42 commits)")

### Embed Badge

![Health badge](/badges/christianberkman-codeigniter4-date-validation/health.svg)

```
[![Health](https://phpackages.com/badges/christianberkman-codeigniter4-date-validation/health.svg)](https://phpackages.com/packages/christianberkman-codeigniter4-date-validation)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
