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
7use ILIAS\Data;
8
9class 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}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:15
__construct(int $max_length, Data\Factory $data_factory, \ilLanguage $lng)
language handling
$txt
Definition: error.php:11
A constraint encodes some resrtictions on values.
Definition: Constraint.php:15