How does TP5.1 do mailbox verification?

for example, I want to verify that this email is legal. How do I want to verify it with TP"s own verification rules? I think the manual defines a User class We define a\ app\ index\ validate\ User validator class for User validation. is it so troublesome for the TP framework to verify mailbox usernames or something? Where should this validator class be written? Is it in the same directory as the controller?

<?php
namespace app\index\controller;
use think\Controller;
use think\facade\Request;
use think\response;
use think\View;
use think\Validate;
class Register extends Controller
{
    public function regcheck(){
        $data=input("email");
        
    }
}
?>
Mar.04,2021

for individual verification, you can call statically

// 
use think\facade\Validate;

Validate::isEmail('thinkphp@qq.com'); // true

if there are many things to verify, it is recommended to use validator
validator class can customize the directory, it is recommended to put it in the \ app\ index\ validate directory.

Validator class

namespace app\index\validate;

use think\Validate;

class User extends Validate
{
    protected $rule =   [
        'name'  => 'require|max:25',
        'email' => 'email',    
    ];
    
    protected $message  =   [
        'name.require' => '',
        'name.max'     => '25',
        'email'        => '',    
    ];
    
}

used in the controller:

namespace app\index\controller;

use think\Controller;

class Index extends Controller
{
    public function index()
    {
        $data = [
            'name'  => 'thinkphp',
            'email' => 'thinkphp@qq.com',
        ];

        $validate = new \app\index\validate\User;

        if (!$validate->check($data)) {
            dump($validate->getError());
        }
    }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31943-2b2f1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31943-2b2f1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?