0

I've started working with Laravel 4 Beta 2 and am running into a problem with the validation.

I have this route :

Route::post('inscription', function()
{   
    $rules = array(
        array('nom' => 'required'),
        array('passe' => 'required')
    );
    $validator = Validator::make(Input::all(), $rules);

    if ($validator->fails())
    {
        echo var_dump(Input::all());
        $messages = $validator->messages();
        print_R($messages->all());
    }
});

And I get that when I enter values in my form :

array (size=2)
  'nom' => string 'Dupont' (length=6)
  'passe' => string 'monpasse' (length=8)

Array ( [0] => The 0 field is required. [1] => The 1 field is required. ) 

That tell me fields are required but there are values !

2 Answers 2

3

Ok I was wrong, here's the correct code :

Route::post('inscription', function()
{   
    $rules = array(
        'nom' => 'required',
        'passe' => 'required'
);
$validator = Validator::make(Input::all(), $rules);

if ($validator->fails())
{
    echo var_dump(Input::all());
    $messages = $validator->messages();
    print_R($messages->all());
}

});

Sign up to request clarification or add additional context in comments.

Comments

0

Since it's a beta version you should create an issue on github to get a good answer for your problem. The community will gladly help you.

https://github.com/laravel/framework

1 Comment

It's not an issue, I made a syntax error in my rules array. Must be a simple array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.