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.
15 class LimitDef
extends IntegerDef
{
20 * Additional `$options` accepted:
21 * - 'parse-limit': (bool) Default true, set false to return 'max' rather
22 * than determining the effective value.
24 public function validate( $name, $value, array $settings, array $options ) {
25 if ( $value === 'max' ) {
26 if ( !isset( $options['parse-limit'] ) ||
$options['parse-limit'] ) {
27 $value = $this->callbacks
->useHighLimits( $options )
28 ?
$settings[self
::PARAM_MAX2
] ??
$settings[self
::PARAM_MAX
] ?? PHP_INT_MAX
29 : $settings[self
::PARAM_MAX
] ?? PHP_INT_MAX
;
34 return parent
::validate( $name, $value, $settings, $options );
37 public function normalizeSettings( array $settings ) {
42 return parent
::normalizeSettings( $settings );