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

findMessages() broken #85

Closed
nickl- opened this issue Aug 16, 2012 · 18 comments
Closed

findMessages() broken #85

nickl- opened this issue Aug 16, 2012 · 18 comments

Comments

@nickl-
Copy link
Member

nickl- commented Aug 16, 2012

As reported by @ed100 in #84

I tried some validations and worked fine.

then I tried to do error messages:

try {
$usernameValidator->assert('really messed up screen#name');
} catch(\InvalidArgumentException $e) {
var_dump($e->findMessages('alnum', 'length', 'noWhitespace'));
}

That give an error:

Catchable fatal error: Argument 1 passed to
Respect\Validation\Exceptions\AbstractNestedException::findMessages()
must be of the type array, string given, called in
/usr/websites/www/validationpage.html on line 14 and defined in
/usr/local/share/pear/Respect/Validation/Exceptions/AbstractNestedException.php
on line 22

also tried on a different try than above:

$errors = $e->findMessages(
'alnum' => '{{name}} must contain only letters and digits',
'length' => '{{name}} must not have more than 15 chars',
'noWhitespace' => '{{name}} cannot contain spaces'
);

and got error:
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in
/usr/websites/www/validationpage.html on line 11

@nickl-
Copy link
Member Author

nickl- commented Aug 16, 2012

Ahh I've seen that one before, please try the development branch it was fixed @b3aaa8c0a37ef90552f88474ce58ab41b2fac4be or don't use findMessage() since that's where the problem is and getMessage() does not suffer the same.

@ed100 Well done now you've gone the full circle so I am keen to see your improvements next. If you don't feel you want to contribute code that is also fine. You obviously have a talent for finding everything possible thing may go wrong and your explanations are very concise and easy to follow. We desperately need a good tester like yourself to comb through the other projects as well if you would be so kind, much obliged.

I was also thinking that we should probably transfer what's been said on #84 to the documentation or start a FAQ to help the next person that comes around. Would you be keen to give us a hand?

No matter how small the contribution we always appreciate it. I cannot start to explain what a huge benefit it's been for us to go through the motions with you and reach a successful resolve.

Thank you very much! Keep up the good work...

@ed100
Copy link

ed100 commented Aug 16, 2012

I will try the dev branch. I would be glad to help as soon as I finish
working on my site. Getting fairly close to having it done. I am not
much of a coder, but can read and write and break things.

On my second try I got the error:
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in
/usr/websites/www/validationpage.html on line 11

that does not seem caused by findMessage.

On 08/16/2012 03:01 PM, Nick Lombard wrote:

Ahh I've seen that one before, please try the development branch it was fixed @b3aaa8c0a37ef90552f88474ce58ab41b2fac4be or don't use findMessage() since that's where the problem is and getMessage() does not suffer the same.

@ed100 Well done now you've gone the full circle so I am keen to see your improvements next. If you don't feel you want to contribute code that is also fine. You obviously have a talent for finding everything possible thing may go wrong and your explanations are very concise and easy to follow. We desperately need a good tester like yourself to comb through the other projects as well if you would be so kind, much obliged.

I was also thinking that we should probably transfer what's been said on #84 to the documentation or start a FAQ to help the next person that comes around. Would you be keen to give us a hand?

No matter how small the contribution we always appreciate it. I cannot start to explain what a huge benefit it's been for us to go through the motions with you and reach a successful resolve.

Thank you very much! Keep up the good work...


Reply to this email directly or view it on GitHub:
#85 (comment)

@nickl-
Copy link
Member Author

nickl- commented Aug 16, 2012

Then break things it is! =) Always nice to know someone has your back. Glad to have you on board!

Let me know if that also fixes findMessages() for you, please.

@ed100
Copy link

ed100 commented Aug 16, 2012

all I need is just the one file from dev branch:
AbstractNestedException.php

On 08/16/2012 03:54 PM, Nick Lombard wrote:

Then break things it is! =) Always nice to know someone has your back. Glad to have you on board!

Let me know if that also fixes findMessages() for you, please.


Reply to this email directly or view it on GitHub:
#85 (comment)

@nickl-
Copy link
Member Author

nickl- commented Aug 16, 2012

I would just replace everything if I were you... just overwrite what is in the pear folder that should do the trick.

@ed100
Copy link

ed100 commented Aug 16, 2012

replace it all with the files from
Respect-Validation-0.4.4-21-g0580308.tar.gz

tried:

try {
$usernameValidator->assert('really messed up screen#name');
} catch(\InvalidArgumentException $e) {
var_dump($e->findMessages('alnum', 'length', 'noWhitespace'));
}

Catchable fatal error: Argument 1 passed to
Respect\Validation\Exceptions\AbstractNestedException::findMessages()
must be of the type array, string given, called in
/usr/websites/www/validationpage.html on line 69 and defined in
/usr/local/share/pear/Respect/Validation/Exceptions/AbstractNestedException.php
on line 22

Now what should I do?

On 08/16/2012 04:10 PM, Nick Lombard wrote:

I would just replace everything if I were you... just overwrite what is in the pear folder that should do the trick.


Reply to this email directly or view it on GitHub:
#85 (comment)

@nickl-
Copy link
Member Author

nickl- commented Aug 16, 2012

Give this one a go:

<?php
try {
    $usernameValidator->assert('really messed up screen#name');
} catch(\InvalidArgumentException $e) {
    var_dump($e->findMessages(array('alnum', 'length', 'noWhitespace')));
}

I am making this leap because findMessages has a type hint array see

<?php
    public function findMessages(array $paths)
    {
    ///
    }

If that doesn't work then I will need to see what you are doing from declaring $usernameValidator up and until the end of the catch please.

@augustohp augustohp reopened this Aug 17, 2012
@augustohp
Copy link
Member

Made the needed corrections on README.md, thanks for point that out @ed100.

@ed100
Copy link

ed100 commented Aug 17, 2012

That does not give a parse error,

The var_dump is:
array(3) { ["alnum"]=> string(79) ""really messed up screen#name" must
contain only letters (a-z) and digits (0-9)" ["length"]=> string(66)
""really messed up screen#name" must have a length between 1 and 15"
["noWhitespace"]=> string(58) ""really messed up screen#name" must not
contain whitespace" }

I looked at the findMessges, and didn't understand what the $paths
meant. I don't remember seeing a function showing parameters as they
are in findMessages(array $paths) thought it was usually more like
findMessages(array,$paths) so I am just confused. I keep showing I an
not a coder.

What I am aiming for is displaying my error message to the use depending
on what is being validated and what the error is.

Then I will have code to end the page so they can fix their error.

On 08/16/2012 06:26 PM, Nick Lombard wrote:

Give this one a go:

<?php
try {
    $usernameValidator->assert('really messed up screen#name');
} catch(\InvalidArgumentException $e) {
    var_dump($e->findMessages(array('alnum', 'length', 'noWhitespace')));
}

I am making this leap because findMessages has a type hint array see

<?php
    public function findMessages(array $paths)
    {
    ///
    }

If that doesn't work then I will need to see what you are doing from declaring $usernameValidator up and until the end of the catch please.


Reply to this email directly or view it on GitHub:
#85 (comment)

@nickl-
Copy link
Member Author

nickl- commented Aug 17, 2012

You can try getFullMessag() or just getMessage() the latter will only have the last error and the first one will return a string with all errors =)

You are a coder after all =) just patience and more confidence it will come.

@nickl-
Copy link
Member Author

nickl- commented Aug 17, 2012

@ed100 What's happening did you have success?

@ed100
Copy link

ed100 commented Aug 17, 2012

not have time to work on it -- was very busy doing a few other things.
over the weekend will be time to work on it.

On 08/17/2012 02:44 PM, Nick Lombard wrote:

@ed100 What's happening did you have success?


Reply to this email directly or view it on GitHub:
#85 (comment)

@nickl-
Copy link
Member Author

nickl- commented Aug 17, 2012

=)

@alganet
Copy link
Member

alganet commented Aug 31, 2012

Hey @ed100, any news on this? Did that worked for you? Please let us know if you're having any problems =)

@alganet
Copy link
Member

alganet commented Nov 27, 2012

findMessages() uses arrays!

        $usernameValidator = Validator::alnum('_')->length(1,15)->noWhitespace();
        try {
            $usernameValidator->assert('really messed up screen#name');
        } catch(\InvalidArgumentException $e) {
            var_dump($e->findMessages(array('alnum', 'length', 'noWhitespace')));
        }

Try this ;)

@augustohp
Copy link
Member

Does this issue still valid? Can we close this?

@ed100
Copy link

ed100 commented Dec 18, 2012

you can close it

Thanks for you help

On 12/18/2012 07:06 AM, Augusto Pascutti wrote:

Does this issue still valid? Can we close this?


Reply to this email directly or view it on GitHub:
#85 (comment)

@augustohp
Copy link
Member

@ed100 Thank you for you feedback man! =D

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

4 participants