3

I want to validate my form input but it throws me this error in my Laravel.log file

production.ERROR: exception 'BadMethodCallException' with message 'Method [validateString] does not exist.' in C:\xampp\htdocs\testing\vendor\laravel\framework\src\Illuminate\Validation\Validator.php:2405

This is my Dog model

class Dog extends Eloquent { // Add your validation rules here public static $rules = [ 'name' => 'required|string', 'age' => 'required|integer' ]; public static $customMessages = array( 'required' => 'Man the Name atribute is REQUIRED. Fill it man.' ); // Don't forget to fill this array protected $fillable = ['name', 'age']; public static function validate($data) { return Validator::make($data, static::$rules); } 

}

And in my DogsController here I validate my data

public function update($id) { $dog = $this->DogRepo->find($id); if($dog) { // $dog = $this->dogRepo->update(array_merge(['id' => $id], Input::all())); $validation = Dog::validate(Input::all()); if ($validation->fails()) { return 'wrong data'; } else { return 'ok data'; } if($dog->save()) { return Redirect::route('dogs.show', $id)->with('message', 'The dog has been updated!'); } return Redirect::route('dogs.edit', $id)->withInput()->withErrors($this->dogRepo->errors()); } App::abort(404); } 

Any Ideas what I'm doing wrong?

Thank you very much for any help.

1 Answer 1

1

In Laravel < 4.2

There is no validation rule named string.

Laravel 4.1 - Validation - Available Rules

In Laravel >= 4.2 there is a string rule

Updated to reflect newer versions of Laravel.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.