Last active
October 2, 2020 10:49
-
-
Save webdevilopers/e071d40d6d0a573f8ef8ac8e78975dc9 to your computer and use it in GitHub Desktop.
Symfony Assert Annotations using external Class constants
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
<?php | |
namespace Sps\Bundle\PriceQuoteBundle\Entity; | |
abstract class AbstractDormerPriceQuote | |
extends PriceQuoteRequest | |
{ | |
const MIN_ROOF_PITCH = 10; | |
const MAX_ROOF_PITCH = 55; | |
} |
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
<?php | |
namespace Sps\PriceQuote\Application\Command; | |
use Sps\Bundle\PriceQuoteBundle\Entity\AbstractDormerPriceQuote; | |
class AbstractRequestPriceQuoteCommand | |
{ | |
/** | |
* @var $roofPitch | |
* @Assert\Range(min=AbstractDormerPriceQuote::MIN_ROOF_PITCH, max="55", groups={ | |
* "flow_dormerRequest_step4", "glasDormerRequest" | |
* }) | |
*/ | |
public $roofPitch; |
Fixed:
/**
* @var $roofPitch
* @Assert\Range(min=AbstractDormerPriceQuote::MIN_ROOF_PITCH, max="55", groups={
* "flow_dormerRequest_step4", "glasDormerRequest"
* })
*/
public $roofPitch;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Following this solution by @ZhukV:
Suggesting to use Doctrine Annotations:
Unfortunately the Range
min
value is not registered -max
works fine.It seems to work with the Expression language though as provided by @localheinz: