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

[BUG] Unhelpful fatal error with custom validator #1664

Closed
quasipickle opened this issue Dec 10, 2013 · 4 comments
Closed

[BUG] Unhelpful fatal error with custom validator #1664

quasipickle opened this issue Dec 10, 2013 · 4 comments

Comments

@quasipickle
Copy link
Contributor

I hesitate to call this a "bug" per se, but it's not really a new feature request. Anyway...

I have built a custom validator. In that validator, when it returns FALSE, I had neglected to append a message. I was then presented with a fatal error saying "the argument is not iterable" - which was fairly close to useless.

I suggest either changing the code so it doesn't choke when no message is appended, or throw a proper exception to help trace where the problem occurred.

@ghost
Copy link

ghost commented Dec 11, 2013

Could you please submit a test case?

@quasipickle
Copy link
Contributor Author

I don't know how to officially and properly build a test case, so I'll just give you the code I had that was causing the error.

Also, I'm using 1.2.4.

use Phalcon\Mvc\Model\Validator,
    Phalcon\Mvc\Model\ValidatorInterface;

class Dollar extends Validator implements ValidatorInterface
{
    public function validate($model)
    {
        $field = $this->getOption('field');
        $value = $model->$field;

        if(preg_match('/^\d+(\.\d{2})?$/',$value))
            return TRUE;
        else{
            return FALSE;
        }
    }
}

@ghost
Copy link

ghost commented Dec 15, 2013

Could you please check now?

@quasipickle
Copy link
Contributor Author

Yep, it works now.

As a side-note, https access of the debug assets (css/js) is broken again. You guys should just include the assets right in the debug error page.

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

2 participants