-
Notifications
You must be signed in to change notification settings - Fork 0
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
29 changed files
with
731 additions
and
78 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
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
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,62 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace C0ntax\ParsleyBundle\Directive\Field\Constraint; | ||
|
||
/** | ||
* Class AbstractComparison | ||
* | ||
* @package C0ntax\ParsleyBundle\Directive\Field\Constraint | ||
*/ | ||
abstract class AbstractComparison extends AbstractConstraint | ||
{ | ||
/** @var int|float|\DateTime */ | ||
private $value; | ||
|
||
/** | ||
* Min constructor. | ||
* | ||
* @param \DateTime|float|int $min | ||
* @param string|null $errorMessage | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function __construct($min, string $errorMessage = null) | ||
{ | ||
$this->setValue($min); | ||
$this->setErrorMessageString($errorMessage); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getViewAttr(): array | ||
{ | ||
$value = null; | ||
if ($this->getValue() instanceof \DateTime || $this->getValue() instanceof \DateTimeImmutable) { | ||
$value = $this->getValue()->format('Y-m-d H:i:s'); | ||
} else { | ||
$value = (string) $this->getValue(); | ||
} | ||
|
||
return $this->getMergedViewAttr($value); | ||
} | ||
|
||
/** | ||
* @return \DateTime|float|int | ||
*/ | ||
private function getValue() | ||
{ | ||
return $this->value; | ||
} | ||
|
||
/** | ||
* @param \DateTime|float|int $min | ||
* @return AbstractComparison | ||
*/ | ||
private function setValue($min): AbstractComparison | ||
{ | ||
$this->value = $min; | ||
|
||
return $this; | ||
} | ||
} |
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
7 changes: 4 additions & 3 deletions
7
src/Constraint/Email.php → src/Directive/Field/Constraint/Email.php
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
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,20 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace C0ntax\ParsleyBundle\Directive\Field\Constraint; | ||
|
||
/** | ||
* Class Min | ||
* | ||
* @package C0ntax\ParsleyBundle\Directive\Field\Constraint | ||
*/ | ||
class Max extends AbstractComparison | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public static function getConstraintId(): string | ||
{ | ||
return 'max'; | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace C0ntax\ParsleyBundle\Directive\Field\Constraint; | ||
|
||
/** | ||
* Class Min | ||
* | ||
* @package C0ntax\ParsleyBundle\Directive\Field\Constraint | ||
*/ | ||
class Min extends AbstractComparison | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public static function getConstraintId(): string | ||
{ | ||
return 'min'; | ||
} | ||
} |
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
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
Oops, something went wrong.