appwrite/src/Appwrite/Auth/Validator/Password.php

70 lines
1.1 KiB
PHP
Raw Normal View History

2019-05-09 06:54:39 +00:00
<?php
namespace Appwrite\Auth\Validator;
2019-05-09 06:54:39 +00:00
use Utopia\Validator;
/**
* Password.
2019-05-09 06:54:39 +00:00
*
* Validates user password string
*/
class Password extends Validator
{
/**
* Get Description.
2019-05-09 06:54:39 +00:00
*
* Returns validator description
*
* @return string
*/
public function getDescription(): string
2019-05-09 06:54:39 +00:00
{
return 'Password must be at least 8 characters';
2019-05-09 06:54:39 +00:00
}
/**
* Is valid.
2019-05-09 06:54:39 +00:00
*
* @param mixed $value
*
2019-05-09 06:54:39 +00:00
* @return bool
*/
public function isValid($value): bool
2019-05-09 06:54:39 +00:00
{
if (!\is_string($value)) {
return false;
2022-05-23 14:54:50 +00:00
}
if (\strlen($value) < 8) {
2019-05-09 06:54:39 +00:00
return false;
}
return true;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}