# Como uso meu validador no plugin?

**URL:** https://meta.discourse.org/t/how-do-i-use-my-validator-in-the-plugin/140839
**Category:** Development
**Created:** [Fevereiro 6, 2020, 10:20am UTC](https://meta.discourse.org/t/how-do-i-use-my-validator-in-the-plugin/140839 "2020-02-06T10:20:15Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Dev\_Work](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dev_work/32/124200_2.png) [@Dev\_Work](https://meta.discourse.org/u/Dev_Work)
#### Post date: [Fevereiro 6, 2020, 10:20am UTC](https://meta.discourse.org/t/how-do-i-use-my-validator-in-the-plugin/140839/2 "2020-02-06T10:20:37Z")

</div>

> [@Dev\_Work](#):
>
> ```plaintext
> 
> ```

a chave como ‘validator’ está presente

e até mesmo um exemplo como este funciona

```plaintext
plugins:
  my_custom_username_validation:
    default: 'system'
    validator: 'UsernameSettingValidator'

```

> [@Developing Discourse Plugins - Part 3 - Add custom site settings](https://meta.discourse.org/t/beginners-guide-to-creating-discourse-plugins-part-3-custom-settings/31115/23):
>
> I was looking how to create a site setting that validates a username, but found there’s a username type to do this. Here the list of site setting types we have today: email username integer regex string list enum Also, you can do custom validations for your plugin settings, it accepts a validator field that expects a Ruby class. You use it like this. plugins: my\_custom\_username\_validation: default: 'system' validator: 'UsernameSettingValidator' You can check the [UsernameSettingVal…](https://github.com/discourse/discourse/blob/master/lib/validators/username_setting_validator.rb)

> <https://github.com/discourse/discourse/blob/main/lib/validators/username_setting_validator.rb>

---

_[View the full topic](https://meta.discourse.org/t/how-do-i-use-my-validator-in-the-plugin/140839)._
