Reference

Guide

V::maxLength()

Checks if the number of characters in the value equals or is below the given maximum

V::maxLength(string $value, $max): bool

Parameters

Name Type Default Description
$value string
$max getkirby.com/docs/reference/objects/asset/alt

Return type

bool

This validator works like (sheet: validators/max) but it always checks for string length, even if a numeric value is given. The max validator will check for the value of the number in that case.

In your code

if(V::maxLength('Lorem ipsum dolor sit amet.', 10)) {
  echo 'Yay, valid!';
}

In fields

fields:
  example:
    label: Example field
    type: text
    validate:
      maxLength: 10

Source code

kirby/src/Toolkit/V.php#L343