Fixes for #5252

Fixes for #5252 and refactoring. Perhaps you need to fix js validation too. I did not watch it.
All tests from https://github.com/yiisoft/yii2/blob/master/tests/unit/framework/validators/RangeValidatorTest.php#L26 is valid