---
application: "Intervention Validation"
version: "Version 4"
status: "stable"
---

# Username Rule

## Validate a Typical Username

Explore how to validate typical usernames with the additional validation rules of Intervention Validation for your Laravel application.

> public Intervention\Validation\Rules\Username::__construct()

The field under validation must be a valid username. Consisting of alpha-numeric characters, underscores, minus and starting with a alphabetic character. Multiple underscore and minus chars are not allowed. Underscore and minus chars are not allowed at the beginning or end.

### Parameters

none

### Example

```php
use Illuminate\Support\Facades\Validator;
use Intervention\Validation\Rules\Username;

$validator = Validator::make($request->all(), [
    'attribute-key' => new Username(),
]);
```

---

## Become a Sponsor

### Intervention Validation needs your help to keep the project going

Intervention Validation is non-commercial, open source licensed and completely free to use. The considerable
effort required to maintain and develop the software is only possible with the financial support
of sponsors. There are two ways in which you can support this project.

- Support via [GitHub Sponsors](https://github.com/sponsors/Intervention)
- Support via [Ko-Fi](https://ko-fi.com/interventionphp)