This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from serato/WEB-9021
[WEB-9021] Move input validations from Profile service to the bootstrap library
- Loading branch information
Showing
4 changed files
with
225 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Serato\SwsApp\Exception; | ||
|
||
use Serato\SwsApp\Http\Rest\Exception\AbstractBadRequestException; | ||
|
||
/** | ||
* Class BadRequestContainHTMLTagsException | ||
* The request param is invalid with html tags | ||
* @package App\Exception\RequestValidation | ||
*/ | ||
class BadRequestContainHTMLTagsException extends AbstractBadRequestException | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
protected $code = 5023; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $message; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Serato\SwsApp\Validation\Rules; | ||
|
||
use Rakit\Validation\Rule; | ||
|
||
class NoHtmlTag extends Rule | ||
{ | ||
/** | ||
* Validation rule name for params without HTML tags. | ||
* @var string | ||
*/ | ||
public const NO_HTML_TAG_RULE = 'no_html_tag'; | ||
/** | ||
* Regex validation rule for params without HTML tags. | ||
* @var string | ||
*/ | ||
public const NO_HTML_TAG_REGEX = '/^(?:(?!<[^>]*$)[^<])*$/'; | ||
|
||
/** @var string */ | ||
protected $message = "The :attribute contains html tag."; | ||
|
||
/** | ||
* Check the $value is valid by checking it does not contain html tags | ||
* | ||
* @param mixed $value | ||
* @return bool | ||
*/ | ||
public function check($value): bool | ||
{ | ||
return preg_match(self::NO_HTML_TAG_REGEX, $value) > 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters