# Custom User Fields - Field Verification

**URL:** https://meta.discourse.org/t/custom-user-fields-field-verification/109574
**Category:** Feature
**Created:** [February 19, 2019, 5:59pm UTC](https://meta.discourse.org/t/custom-user-fields-field-verification/109574 "2019-02-19T17:59:31Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![snoopdouglas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/snoopdouglas/32/186414_2.png) [@snoopdouglas](https://meta.discourse.org/u/snoopdouglas)
#### Post date: [August 10, 2020, 1:25pm UTC](https://meta.discourse.org/t/custom-user-fields-field-verification/109574/12 "2020-08-10T13:25:33Z")

</div>

Apologies for the lateness of the hour on this one - but for anyone scouring Meta to try and find out how to validate any custom fields you might’ve added, I thought it’d be worth mentioning how to do this with a plugin.

In your `plugin.rb`, use the `validate` method on `User`. You can then poke at your custom fields and set an error if any are invalid:

```ruby
require_dependency 'user'

validate User, :my_cool_validation_method do
  field = self.custom_fields['cool_tapes']
  if ! field.blank? && field.include?("bag of four grapes")
    self.errors[:cool_tapes] << "No rhymes allowed."
  end
end

```

nb. the `:my_cool_validation_method` symbol can be anything you want, but should be unique within the context of the `User` model.

---

_[View the full topic](https://meta.discourse.org/t/custom-user-fields-field-verification/109574)._
