Skip to content

Valitron Issues Fixed

Valicomb is a modernized fork of vlucas/valitron. This page documents known issues from the original library that have been fixed in Valicomb.


These issues caused incorrect validation results or PHP errors in the original library.

Fixed Valitron #368

Problem: Empty strings incorrectly passed the integer validation rule.

// In Valitron - BUG: This passes validation
$v = new Validator(['num' => '']);
$v->rule('integer', 'num');
$v->validate(); // true (incorrect!)

Fix: Valicomb uses filter_var() with FILTER_VALIDATE_INT which correctly rejects empty strings.

// In Valicomb - This correctly fails
$v = new Validator(['num' => '']);
$v->rule('integer', 'num');
$v->validate(); // false (correct!)

Fixed Valitron #356

Problem: Empty strings incorrectly passed lengthMin and lengthBetween validation rules.

// In Valitron - BUG: This passes validation
$v = new Validator(['text' => '']);
$v->rule('lengthMin', 'text', 1);
$v->validate(); // true (incorrect!)

Fix: Valicomb correctly calculates string length and compares against the minimum.

// In Valicomb - This correctly fails
$v = new Validator(['text' => '']);
$v->rule('lengthMin', 'text', 1);
$v->validate(); // false (correct!)

Fixed Valitron #260

Problem: Empty arrays incorrectly passed the required validation rule.

// In Valitron - BUG: This passes validation
$v = new Validator(['items' => []]);
$v->rule('required', 'items');
$v->validate(); // true (incorrect!)

Fix: Valicomb now treats empty arrays as empty values that fail required validation.

// In Valicomb - This correctly fails
$v = new Validator(['items' => []]);
$v->rule('required', 'items');
$v->validate(); // false (correct!)
// Non-empty arrays still pass
$v = new Validator(['items' => ['apple', 'banana']]);
$v->rule('required', 'items');
$v->validate(); // true (correct!)

Fixed Valitron #381 #370 #357

Problem: PHP 8.1+ throws deprecation warnings when null is passed to strtotime().

// In Valitron - PHP 8.1+ deprecation warning
Deprecated: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated

Fix: Valicomb validates input types before calling strtotime() and uses explicit string casts.

// In Valicomb - No deprecation warnings
// All strtotime() calls are protected with type checks
if (!is_string($value)) {
return false;
}
// Or use explicit casting
$timestamp = strtotime((string)$value);

Array Validation on Non-Arrays Causes Warnings

Section titled “Array Validation on Non-Arrays Causes Warnings”

Fixed Valitron #182

Problem: Using array validation rules on non-array values caused PHP warnings.

// In Valitron - BUG: PHP Warning
$v = new Validator(['field' => 'not an array']);
$v->rule('array', 'field');
$v->validate(); // Warning: Invalid argument supplied for foreach()

Fix: Valicomb checks input types before performing array operations.

// In Valicomb - Clean failure, no warnings
$v = new Validator(['field' => 'not an array']);
$v->rule('array', 'field');
$v->validate(); // false (no warnings!)

Fixed Valitron #70

Problem: The value 0 was sometimes incorrectly handled in min/max validation due to PHP’s type juggling.

Fix: Valicomb uses is_numeric() checks and high-precision bccomp() for numeric comparisons.


Fixed Valitron #273

Problem: URL validation threw errors when the input was an object instead of a string.

Fix: Valicomb validates input types before processing, returning false for non-string values.


These features were requested in Valitron issues and have been implemented in Valicomb.

requiredWith / requiredWithout

Conditional validation based on other fields (#267)

IPv4 / IPv6 / ASCII

Network and character validation rules (#261)

startsWith / endsWith

String prefix and suffix validation (#170)

arrayHasKeys

Validate required array keys (#280)


Valicomb includes updated and corrected translations for all 33 supported languages, addressing issues reported in:

  • #372 - Russian translation corrections
  • #367 - Spanish array validator message
  • #353 - Spanish length rule clarification
  • And many more language improvements

IssueDescriptionStatus
#368Empty strings pass integer validationFixed
#356Empty strings pass length validationFixed
#260Empty arrays pass required validationFixed
#381, #370, #357PHP 8.1+ strtotime deprecationFixed
#182Array validation causes PHP warningsFixed
#273URL validation with objectsFixed
#70Min validation with zeroFixed
#267requiredWith/requiredWithout rulesAdded
#261IPv4/IPv6/ASCII rulesAdded
#170startsWith/endsWith rulesAdded
#280arrayHasKeys ruleAdded

Found a bug or have a feature request?

  • GitHub Issues
  • For security issues, please use GitHub’s private security advisory feature