We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to validate in micro phalcon

Hi. How to validation data from request API? and how to validation for required field in micro phalcon with validation\validator

you can validate each request after you received it in controller action.

maybe my code can help you.

    $name = $this->request->getPost("name");
    $email = $this->request->getPost("email");
    $password = $this->request->getPost("password");
    $validation = new Validation();
    $validation->add(
        'name',
        new PresenceOf(
            [
                'message' => 'The name is required',
            ]
        )
    );
    $validation->add(
        'email',
        new Email(
            [
                'message' => 'Email not valid',
            ]
        )
    );
    $validation->add(
        'password',
        new PresenceOf(
            [
                'message' => 'The password is required',
            ]
        )
    );
    $arr = array(
        "name"=>$name,
        "email"=>$email,
        "password"=>$password
    );
    $messages = $validation->validate($arr);
    if (count($messages)) {
        foreach ($messages as $message) {
            echo $message, '<br>';
    }

Also i would suggest putting this code into separated class.