3 namespace Wikimedia\ParamValidator\TypeDef
;
6 * Type definition for "limit" types
8 * A limit type is an integer type that also accepts the magic value "max".
9 * IntegerDef::PARAM_MIN defaults to 0 for this type.
14 class LimitDef
extends IntegerDef
{
19 * Additional `$options` accepted:
20 * - 'parse-limit': (bool) Default true, set false to return 'max' rather
21 * than determining the effective value.
23 public function validate( $name, $value, array $settings, array $options ) {
24 if ( $value === 'max' ) {
25 if ( !isset( $options['parse-limit'] ) ||
$options['parse-limit'] ) {
26 $value = $this->callbacks
->useHighLimits( $options )
27 ?
$settings[self
::PARAM_MAX2
] ??
$settings[self
::PARAM_MAX
] ?? PHP_INT_MAX
28 : $settings[self
::PARAM_MAX
] ?? PHP_INT_MAX
;
33 return parent
::validate( $name, $value, $settings, $options );
36 public function normalizeSettings( array $settings ) {
41 return parent
::normalizeSettings( $settings );