Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate Integer by Numeric rule throw TypeError #246

Closed
h4kuna opened this issue May 15, 2020 · 0 comments
Closed

Validate Integer by Numeric rule throw TypeError #246

h4kuna opened this issue May 15, 2020 · 0 comments

Comments

@h4kuna
Copy link
Contributor

h4kuna commented May 15, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant