# HasMinlength

> Provides an immutable API for the minlength attribute.

[API reference](/docs/api/index.md) › [HTML](/docs/extensions/html/reference/index.md) › [Form](/docs/extensions/html/reference/form/index.md) › [Mixin](/docs/extensions/html/reference/form/mixin/index.md) › HasMinlength

| trait | `UIAwesome\Html\Form\Mixin\HasMinlength` |
| --- | --- |
| Uses traits | [`HasIntLikeAttribute`](/docs/extensions/html/reference/form/mixin/hasintlikeattribute/index.md) |
| Source | [`src/Form/Mixin/HasMinlength.php`](https://github.com/ui-awesome/html/blob/main/src/Form/Mixin/HasMinlength.php#L19) |

Used by 7 types:

- [`UIAwesome\Html\Form\InputEmail`](/docs/extensions/html/reference/form/inputemail/index.md)
- [`UIAwesome\Html\Form\InputPassword`](/docs/extensions/html/reference/form/inputpassword/index.md)
- [`UIAwesome\Html\Form\InputSearch`](/docs/extensions/html/reference/form/inputsearch/index.md)
- [`UIAwesome\Html\Form\InputTel`](/docs/extensions/html/reference/form/inputtel/index.md)
- [`UIAwesome\Html\Form\InputText`](/docs/extensions/html/reference/form/inputtext/index.md)
- [`UIAwesome\Html\Form\InputUrl`](/docs/extensions/html/reference/form/inputurl/index.md)
- [`UIAwesome\Html\Form\TextArea`](/docs/extensions/html/reference/form/textarea/index.md)

Provides an immutable API for the `minlength` attribute.

See also: <https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/minlength>.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`minlength()`](#method-minlength) | Sets the `minlength` attribute. | `HasMinlength` |

## Method details

### minlength() <span id="method-minlength"></span>

```php
public function minlength(int|string|Stringable|UnitEnum|null $value): static
```

Sets the `minlength` attribute.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `int\|string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | Minimum length. Must be '>= 0', or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `minlength` attribute.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): if the value is not an integer-like value '>= 0'.