Skip to content

Contributing

Thank you for your interest in contributing to Valicomb!

Terminal window
# Clone your fork
git clone https://github.com/YOUR_USERNAME/valicomb.git
cd valicomb
# Install dependencies
composer install
# Verify setup
composer check-all

Requirements: PHP 8.2+, Composer, Git


  • PHP 8.2+ with declare(strict_types=1);
  • PSR-12 coding standard (run composer cs-fix to auto-fix)
  • PHPStan Level 8 - all code must pass static analysis

Before submitting a PR, always run:

Terminal window
composer check-all

This runs tests, PHPStan, and code style checks.


Add to the appropriate trait in src/Valicomb/Validators/:

TraitRule Types
StringValidatorsTraitString patterns, format
NumericValidatorsTraitNumbers, ranges
DateValidatorsTraitDates, times
ArrayValidatorsTraitArrays, collections
NetworkValidatorsTraitIPs, emails, URLs
LengthValidatorsTraitString length
ComparisonValidatorsTraitField comparison
ConditionalValidatorsTraitConditional rules
TypeValidatorsTraitType checking
protected function validateMyRule(
string $field,
mixed $value,
array $params,
array $fields
): bool {
// Return true if valid, false if invalid
}

Add the error message to src/lang/en.php:

'myRule' => '{field} failed the myRule validation',

Create tests in tests/Valicomb/Rules/:

public function testMyRuleValid(): void
{
$v = new Validator(['field' => 'valid_value']);
$v->rule('myRule', 'field');
$this->assertTrue($v->validate());
}
public function testMyRuleInvalid(): void
{
$v = new Validator(['field' => 'invalid_value']);
$v->rule('myRule', 'field');
$this->assertFalse($v->validate());
}

Add documentation to the appropriate rules page in docs/.


Do NOT create public issues for security vulnerabilities.

Create a private security advisory on GitHub or email the maintainer directly.


By contributing, you agree that your contributions will be licensed under the BSD 3-Clause License.