Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InputException.php
Go to the documentation of this file.
1 <?php
8 
10 
18 {
22  const DEFAULT_MESSAGE = 'One or more input exceptions have occurred.';
23 
27  const INVALID_FIELD_RANGE = 'The %fieldName value of "%value" must be between %minValue and %maxValue';
28 
32  const INVALID_FIELD_MIN_VALUE = 'The %fieldName value of "%value" must be greater than or equal to %minValue.';
33 
37  const INVALID_FIELD_MAX_VALUE = 'The %fieldName value of "%value" must be less than or equal to %maxValue.';
38 
42  const INVALID_FIELD_VALUE = 'Invalid value of "%value" provided for the %fieldName field.';
43 
47  const REQUIRED_FIELD = '"%fieldName" is required. Enter and try again.';
48 
56  public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0)
57  {
58  if ($phrase === null) {
59  $phrase = new Phrase('One or more input exceptions have occurred.');
60  }
61  parent::__construct($phrase, $cause, $code);
62  }
63 
72  public static function invalidFieldValue($fieldName, $fieldValue, \Exception $cause = null)
73  {
74  return new self(
75  new Phrase(
76  'Invalid value of "%value" provided for the %fieldName field.',
77  ['fieldName' => $fieldName, 'value' => $fieldValue]
78  ),
79  $cause
80  );
81  }
82 
89  public static function requiredField($fieldName)
90  {
91  return new self(
92  new Phrase('"%fieldName" is required. Enter and try again.', ['fieldName' => $fieldName])
93  );
94  }
95 }
static invalidFieldValue($fieldName, $fieldValue, \Exception $cause=null)
__construct(Phrase $phrase=null, \Exception $cause=null, $code=0)
$code
Definition: info.phtml:12