Skip to content

Validate Integer by Numeric rule throw TypeError #246

Description

@h4kuna

Version: 3.0.4

I know this is uninteresting use case.

Bug Description

If you want validate Integer by Numeric rule, than throw exception.

Steps To Reproduce

Here is form for sanbox. Let's fill value and send.

<?php declare(strict_types=1);

namespace App\Presenters;

use Nette\Application\UI\Form;

final class HomepagePresenter extends BasePresenter
{

	protected function createComponentForm()
	{
		$form = new Form();
		$form->addInteger('trim')
			->addCondition($form::FILLED)
			->addRule($form::NUMERIC, 'Musí být číslo.');
//	my fix	->addRule($form::FILLED, 'Musí být číslo.');
		
		$form->addSubmit('send');

		$form->onSuccess[] = function ($form, $values) {
			dumpe($values);
		};

		return $form;
	}

}

Expected Behavior

The form try to validate input value.

Possible Solution

In Validator::validateNumeric expected string but int given. Maybe cast value?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions