Contributing
Thank you for your interest in contributing to Valicomb!
# Clone your forkgit clone https://github.com/YOUR_USERNAME/valicomb.gitcd valicomb
# Install dependenciescomposer install
# Verify setupcomposer check-allRequirements: PHP 8.2+, Composer, Git
Code Standards
Section titled “Code Standards”- PHP 8.2+ with
declare(strict_types=1); - PSR-12 coding standard (run
composer cs-fixto auto-fix) - PHPStan Level 8 - all code must pass static analysis
Before submitting a PR, always run:
composer check-allThis runs tests, PHPStan, and code style checks.
Adding Validation Rules
Section titled “Adding Validation Rules”1. Add the Method
Section titled “1. Add the Method”Add to the appropriate trait in src/Valicomb/Validators/:
| Trait | Rule Types |
|---|---|
StringValidatorsTrait | String patterns, format |
NumericValidatorsTrait | Numbers, ranges |
DateValidatorsTrait | Dates, times |
ArrayValidatorsTrait | Arrays, collections |
NetworkValidatorsTrait | IPs, emails, URLs |
LengthValidatorsTrait | String length |
ComparisonValidatorsTrait | Field comparison |
ConditionalValidatorsTrait | Conditional rules |
TypeValidatorsTrait | Type checking |
protected function validateMyRule( string $field, mixed $value, array $params, array $fields): bool { // Return true if valid, false if invalid}2. Add Language String
Section titled “2. Add Language String”Add the error message to src/lang/en.php:
'myRule' => '{field} failed the myRule validation',3. Add Tests
Section titled “3. Add Tests”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());}4. Document
Section titled “4. Document”Add documentation to the appropriate rules page in docs/.
Security Issues
Section titled “Security Issues”Do NOT create public issues for security vulnerabilities.
Create a private security advisory on GitHub or email the maintainer directly.
License
Section titled “License”By contributing, you agree that your contributions will be licensed under the BSD 3-Clause License.