ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ILIAS\Validation\Constraints\HasMaxLength Class Reference
+ Inheritance diagram for ILIAS\Validation\Constraints\HasMaxLength:
+ Collaboration diagram for ILIAS\Validation\Constraints\HasMaxLength:

Public Member Functions

 __construct (int $max_length, Data\Factory $data_factory, \ilLanguage $lng)
 
- Public Member Functions inherited from ILIAS\Validation\Constraints\Custom
 __construct (callable $is_ok, $error, Data\Factory $data_factory, \ilLanguage $lng)
 If $error is a callable it needs to take two parameters: More...
 
 check ($value)
 Checks the provided value.Should not throw if accepts($value).
Exceptions
More...
 
 accepts ($value)
 Tells if the provided value complies.
Parameters
mixed$value
Returns
bool
More...
 
 problemWith ($value)
 Tells what the problem with the provided value is.Should return null if accepts($value).
Parameters
mixed$value
Returns
string|null
More...
 
 restrict (Result $result)
 Restricts a Result.Must do nothing with the result if $result->isError(). Must replace the result with an error according to problemWith() if !accepts($result->value()).
Parameters
Result$result
Returns
Result
More...
 
 withProblemBuilder (callable $builder)
 Get a constraint like this one with a builder for a custom error message.problemWith() must return an error message according to the new builder for the new constraint.The builder needs to be callable that takes two parameters:
Parameters
callable$builder
Returns
Constraint
More...
 
 getErrorMessage ($value)
 Get the problem message. More...
 

Protected Attributes

 $max_length
 
- Protected Attributes inherited from ILIAS\Validation\Constraints\Custom
 $data_factory
 
 $lng
 
 $is_ok
 
 $error
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS\Validation\Constraints\Custom
 getLngClosure ()
 Get the closure to be passed to the error-function that does i18n and sprintf. More...
 

Detailed Description

Definition at line 9 of file HasMaxLength.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Validation\Constraints\HasMaxLength::__construct ( int  $max_length,
Data\Factory  $data_factory,
\ilLanguage  $lng 
)

Definition at line 16 of file HasMaxLength.php.

References ILIAS\Validation\Constraints\Custom\$data_factory, ILIAS\Validation\Constraints\Custom\$lng, ILIAS\Validation\Constraints\HasMaxLength\$max_length, and $txt.

17  {
18  $this->max_length = $max_length;
19  parent::__construct(
20  function ($value) {
21  return strlen($value) <= $this->max_length;
22  },
23  function ($txt, $value) {
24  return $txt("not_max_length", $this->max_length);
25  },
27  $lng
28  );
29  }
$txt
Definition: error.php:11

Field Documentation

◆ $max_length

ILIAS\Validation\Constraints\HasMaxLength::$max_length
protected

The documentation for this class was generated from the following file: