Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
CredentialsValidator Class Reference

Public Member Functions

 validate ($username, $password)
 

Detailed Description

Validator Helper for user credentials

Definition at line 14 of file CredentialsValidator.php.

Member Function Documentation

◆ validate()

validate (   $username,
  $password 
)

Validate user credentials

Parameters
string$username
string$password
Exceptions
InputException
Returns
void

Definition at line 24 of file CredentialsValidator.php.

25  {
26  $exception = new InputException();
27  if (!is_string($username) || strlen($username) == 0) {
28  $exception->addError(__('"%fieldName" is required. Enter and try again.', ['fieldName' => 'username']));
29  }
30  if (!is_string($password) || strlen($password) == 0) {
31  $exception->addError(__('"%fieldName" is required. Enter and try again.', ['fieldName' => 'password']));
32  }
33  if ($exception->wasErrorAdded()) {
34  throw $exception;
35  }
36  }
__()
Definition: __.php:13

The documentation for this class was generated from the following file: