Implementation of custom validator in thinkPHP5 framework
Jun 11, 2018 am 10:04 AMThis article mainly introduces the implementation method of the thinkPHP5 framework custom validator, and analyzes the specific definition and usage of thinkPHP custom validator in the form of examples. Friends in need can refer to the following
The examples of this article are described Developed the thinkPHP5 framework custom validator implementation method. Share it with everyone for your reference, the details are as follows:
The ordinary validator manual is very detailed, let’s explain how to customize a validator
First we create the validata file in the module directory Folder
Then create a class in it and name it IdMustInt.php
The code is as follows: Note that my module is called api, so the namespace is as follows
Protect attributes $rule is an official rule and cannot be changed. In fact, the verification rules require are all encapsulated function names, so we also create a method. The method name is filled in after the verification rule.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Next, let’s look at our controller The corresponding operations
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
##The above is the entire content of this article. I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website! Related recommendations:
Analysis of functions and usage of widgets in thinkPHP5 framework
The above is the detailed content of Implementation of custom validator in thinkPHP5 framework. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What should I do if I get an error when deploying thinkphp5 in Pagoda?

What should I do if thinkphp5 post cannot get the value?

How to get the requested URL in thinkphp5

What should I do if thinkphp5 url rewriting fails?

How to remove thinkphp5 title bar icon

What should I do if thinkphp5 prompts that the controller does not exist?

How to query yesterday's data in ThinkPHP5

How to set error prompts in thinkphp5
