1
0
Fork 0
mirror of synced 2024-07-03 05:31:38 +12:00
appwrite/src/Appwrite/Network/Validator/URL.php

67 lines
1.1 KiB
PHP
Raw Normal View History

2021-03-24 06:27:51 +13:00
<?php
/**
* Utopia PHP Framework
*
* @package Framework
* @subpackage Validator
*
* @link https://github.com/utopia-php/framework
* @author Appwrite Team <team@appwrite.io>
* @license The MIT License (MIT) <http://www.opensource.org/licenses/mit-license.php>
*/
2021-03-25 06:47:17 +13:00
namespace Appwrite\Network\Validator;
2021-03-24 06:27:51 +13:00
use Utopia\Validator;
/**
* URL
*
* Validate that an variable is a valid URL
*
* @package Utopia\Validator
*/
class URL extends Validator
{
/**
* Get Description
*
* Returns validator description
*
* @return string
*/
public function getDescription()
{
return 'Value must be a valid URL';
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType()
{
return self::TYPE_STRING;
}
/**
* Is valid
*
* Validation will pass when $value is valid URL.
*
* @param mixed $value
* @return bool
*/
public function isValid($value)
{
if (\filter_var($value, FILTER_VALIDATE_URL) === false) {
return false;
}
return true;
}
}