Open
Description
What steps will reproduce the problem?
Validator determines reason of validation error incorrectly if used HHVM and IDN enabled.
use kdn\yii2\validators\DomainValidator;
$validator = new DomainValidator(['enableIDN' => true]);
$validator->validate('-example.com', $error);
echo $error;
What is the expected result?
Each label of the input value should start and end with letter or number. The rightmost label of the input value should start with letter.
What do you get instead?
the input value is too long.
Additional info
Q | A |
---|---|
Extension version | All |
Yii version | All |
PHP version | - |
HHVM version | All |
Operating system | All |
Solution
There was bug in HHVM function idn_to_ascii
, it was fixed. You have the following options:
- Upgrade to most recent version of HHVM (recommended).
- Set property
simpleErrorMessage
totrue
:
use kdn\yii2\validators\DomainValidator;
$validator = new DomainValidator(['enableIDN' => true, 'simpleErrorMessage' => true]);
$validator->validate('-example.com', $error);
echo $error;
Result will be the input value is invalid
for all error cases. It is not perfect because doesn't explain the reason to user but correct.