Validation | 您所在的位置:网站首页 › teamvalidationfailed › Validation |
Validation
Introduction
Validation Quickstart
Defining the Routes
Creating the Controller
Writing the Validation Logic
Displaying the Validation Errors
Repopulating Forms
A Note on Optional Fields
Validation Error Response Format
Form Request Validation
Creating Form Requests
Authorizing Form Requests
Customizing the Error Messages
Preparing Input for Validation
Manually Creating Validators
Automatic Redirection
Named Error Bags
Customizing the Error Messages
Performing Additional Validation
Working With Validated Input
Working With Error Messages
Specifying Custom Messages in Language Files
Specifying Attributes in Language Files
Specifying Values in Language Files
Available Validation Rules
Conditionally Adding Rules
Validating Arrays
Validating Nested Array Input
Error Message Indexes and Positions
Validating Files
Validating Passwords
Custom Validation Rules
Using Rule Objects
Using Closures
Implicit Rules
Introduction
Laravel provides several different approaches to validate your application's incoming data. It is most common to use the validate method available on all incoming HTTP requests. However, we will discuss other approaches to validation as well. Laravel includes a wide variety of convenient validation rules that you may apply to data, even providing the ability to validate if values are unique in a given database table. We'll cover each of these validation rules in detail so that you are familiar with all of Laravel's validation features. Validation QuickstartTo learn about Laravel's powerful validation features, let's look at a complete example of validating a form and displaying the error messages back to the user. By reading this high-level overview, you'll be able to gain a good general understanding of how to validate incoming request data using Laravel: Defining the RoutesFirst, let's assume we have the following routes defined in our routes/web.php file: use App\Http\Controllers\PostController; Route::get('/post/create', [PostController::class, 'create']);Route::post('/post', [PostController::class, 'store']);The GET route will display a form for the user to create a new blog post, while the POST route will store the new blog post in the database. Creating the ControllerNext, let's take a look at a simple controller that handles incoming requests to these routes. We'll leave the store method empty for now: |
今日新闻 |
推荐新闻 |
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 |