ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
HasMaxLength.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 2017 Jesús López <lopez@leifos.com> Extended GPL, see docs/LICENSE */
3 
5 
7 use ILIAS\Data;
8 
9 class HasMaxLength extends Custom implements Constraint
10 {
14  protected $max_length;
15 
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  }
30 }
A constraint encodes some resrtictions on values.
Definition: Constraint.php:14
Builds data types.
Definition: Factory.php:14
$txt
Definition: error.php:11
__construct(int $max_length, Data\Factory $data_factory, \ilLanguage $lng)
language handling