use Cake\Validation\Validator; $validator = new Validator(); $validator->email('email'); $errors = $validator->errors([ 'email' => 'not-an-email' ]); // $errors will contain an array of error messagesIn this example, the `email` method of the Validator object is used to set up a validation rule for the `email` field. When the `errors` method is called with a data array, the Validator object checks that the email field contains a valid email address and returns an array of error messages if it does not. The cake.validation package is part of the CakePHP framework.