-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
370 additions
and
2 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
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,44 @@ | ||
<?php | ||
|
||
namespace MPScholten\RequestParser\Validator; | ||
|
||
class StringBetweenParser extends AbstractBetweenParser | ||
{ | ||
protected function describe() | ||
{ | ||
return "a string with character length between $this->minValue and $this->maxValue"; | ||
} | ||
|
||
/** | ||
* @param $value | ||
* @return int | ||
*/ | ||
protected function parse($value) | ||
{ | ||
if (!is_string($value)) { | ||
return null; | ||
} | ||
$value = strlen($value); | ||
return parent::parse($value); | ||
} | ||
|
||
/** | ||
* @param string $defaultValue | ||
* @return string | ||
*/ | ||
public function defaultsTo($defaultValue) | ||
{ | ||
return parent::defaultsTo($defaultValue); | ||
} | ||
|
||
/** | ||
* @throws \Exception | ||
* @param string $invalidValueMessage | ||
* @param string $notFoundMessage | ||
* @return string | ||
*/ | ||
public function required($invalidValueMessage = null, $notFoundMessage = null) | ||
{ | ||
return parent::required($invalidValueMessage, $notFoundMessage); | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
|
||
namespace MPScholten\RequestParser\Validator; | ||
|
||
class StringLargerThanOrEqualToParser extends AbstractLargerThanOrEqualToParser | ||
{ | ||
protected function describe() | ||
{ | ||
return "a string longer than or equal to $this->minValue characters"; | ||
} | ||
|
||
/** | ||
* @param $value | ||
* @return int | ||
*/ | ||
protected function parse($value) | ||
{ | ||
if (!is_string($value)) { | ||
return null; | ||
} | ||
$value = strlen($value); | ||
return parent::parse($value); | ||
} | ||
|
||
/** | ||
* @param string $defaultValue | ||
* @return string | ||
*/ | ||
public function defaultsTo($defaultValue) | ||
{ | ||
return parent::defaultsTo($defaultValue); | ||
} | ||
|
||
/** | ||
* @throws \Exception | ||
* @param string $invalidValueMessage | ||
* @param string $notFoundMessage | ||
* @return string | ||
*/ | ||
public function required($invalidValueMessage = null, $notFoundMessage = null) | ||
{ | ||
return parent::required($invalidValueMessage, $notFoundMessage); | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
|
||
namespace MPScholten\RequestParser\Validator; | ||
|
||
class StringLargerThanParser extends AbstractLargerThanParser | ||
{ | ||
protected function describe() | ||
{ | ||
return "a string longer than $this->minValue characters"; | ||
} | ||
|
||
/** | ||
* @param $value | ||
* @return int | ||
*/ | ||
protected function parse($value) | ||
{ | ||
if (!is_string($value)) { | ||
return null; | ||
} | ||
$value = strlen($value); | ||
return parent::parse($value); | ||
} | ||
|
||
/** | ||
* @param string $defaultValue | ||
* @return string | ||
*/ | ||
public function defaultsTo($defaultValue) | ||
{ | ||
return parent::defaultsTo($defaultValue); | ||
} | ||
|
||
/** | ||
* @throws \Exception | ||
* @param string $invalidValueMessage | ||
* @param string $notFoundMessage | ||
* @return string | ||
*/ | ||
public function required($invalidValueMessage = null, $notFoundMessage = null) | ||
{ | ||
return parent::required($invalidValueMessage, $notFoundMessage); | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
|
||
namespace MPScholten\RequestParser\Validator; | ||
|
||
class StringSmallerThanOrEqualToParser extends AbstractSmallerThanOrEqualToParser | ||
{ | ||
protected function describe() | ||
{ | ||
return "a string shorter than or equal to $this->maxValue characters"; | ||
} | ||
|
||
/** | ||
* @param $value | ||
* @return int | ||
*/ | ||
protected function parse($value) | ||
{ | ||
if (!is_string($value)) { | ||
return null; | ||
} | ||
$value = strlen($value); | ||
return parent::parse($value); | ||
} | ||
|
||
/** | ||
* @param string $defaultValue | ||
* @return string | ||
*/ | ||
public function defaultsTo($defaultValue) | ||
{ | ||
return parent::defaultsTo($defaultValue); | ||
} | ||
|
||
/** | ||
* @throws \Exception | ||
* @param string $invalidValueMessage | ||
* @param string $notFoundMessage | ||
* @return string | ||
*/ | ||
public function required($invalidValueMessage = null, $notFoundMessage = null) | ||
{ | ||
return parent::required($invalidValueMessage, $notFoundMessage); | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
|
||
namespace MPScholten\RequestParser\Validator; | ||
|
||
class StringSmallerThanParser extends AbstractSmallerThanParser | ||
{ | ||
protected function describe() | ||
{ | ||
return "a string shorter than $this->maxValue characters"; | ||
} | ||
|
||
/** | ||
* @param $value | ||
* @return int | ||
*/ | ||
protected function parse($value) | ||
{ | ||
if (!is_string($value)) { | ||
return null; | ||
} | ||
$value = strlen($value); | ||
return parent::parse($value); | ||
} | ||
|
||
/** | ||
* @param string $defaultValue | ||
* @return string | ||
*/ | ||
public function defaultsTo($defaultValue) | ||
{ | ||
return parent::defaultsTo($defaultValue); | ||
} | ||
|
||
/** | ||
* @throws \Exception | ||
* @param string $invalidValueMessage | ||
* @param string $notFoundMessage | ||
* @return string | ||
*/ | ||
public function required($invalidValueMessage = null, $notFoundMessage = null) | ||
{ | ||
return parent::required($invalidValueMessage, $notFoundMessage); | ||
} | ||
} |
Oops, something went wrong.