<commit_before># Emoji::Validator

[![Maintainability](https://api.codeclimate.com/v1/badges/f8a989a176a6d58701bb/maintainability)](https://codeclimate.com/github/brafales/emoji-validator/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/f8a989a176a6d58701bb/test_coverage)](https://codeclimate.com/github/brafales/emoji-validator/test_coverage)
[![Build Status](https://travis-ci.org/brafales/emoji-validator.svg?branch=master)](https://travis-ci.org/brafales/emoji-validator)

We all love emojis, but sometimes unfortunately we can't handle them. Use these two validators to seamlessly ensure they don't end up messing up with your models.

Supports ActiveModel > 4

Tested against Ruby 2.3, 2.4, 2.5 and 2.6

Depends on the [unicode-emoji](https://rubygems.org/gems/unicode-emoji) gem.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'emoji-validator'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install emoji-validator

## Usage

Two validators are provided in the gem:

### Disallow emojis on all attributes for your model
Use the `NoEmojiAnywhereValidator` to make all attributes of your ActiveRecord class automatically validate against emojis:
```ruby
class Person < ActiveRecord::Base
  include Emoji::Validator::NoEmojiAnywhereValidator
end

person = Person.new(first_name: "😃", last_name: "😃")
person.valid? #false
person.errors.count #2
```

### Disallow emojis on single attributes for your model
Use the `NoEmojiValidator` to make single attributes of your ActiveRecord class validate against emojis:
```ruby<commit_msg>Tidy up README.md<commit_after># Emoji::Validator

[![Maintainability](https://api.codeclimate.com/v1/badges/f8a989a176a6d58701bb/maintainability)](https://codeclimate.com/github/brafales/emoji-validator/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/f8a989a176a6d58701bb/test_coverage)](https://codeclimate.com/github/brafales/emoji-validator/test_coverage)
[![Build Status](https://travis-ci.org/brafales/emoji-validator.svg?branch=master)](https://travis-ci.org/brafales/emoji-validator)

We all love emojis, but sometimes unfortunately we can't handle them. Use these two validators to seamlessly ensure they don't end up messing up with your models.

Supports ActiveModel > 4

Tested against Ruby 2.5, 2.6 and 2.7

Depends on the [unicode-emoji](https://rubygems.org/gems/unicode-emoji) gem.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'emoji-validator'
```

And then execute:

```bash
bundle
```

Or install it yourself as:

```bash
gem install emoji-validator
```

## Usage

Two validators are provided in the gem:

### Disallow emojis on all attributes for your model

Use the `NoEmojiAnywhereValidator` to make all attributes of your ActiveRecord class automatically validate against emojis:

```ruby
class Person < ActiveRecord::Base
  include Emoji::Validator::NoEmojiAnywhereValidator
end

person = Person.new(first_name: "😃", last_name: "😃")
person.valid? #false
person.errors.count #2
```

### Disallow emojis on single attributes for your model

Use the `NoEmojiValidator` to make single attributes of your ActiveRecord class validate against emojis:

```ruby
{'fraction_non_alphanumeric': 0.11418898122499231, 'fraction_numerical': 0.02277623884272084, 'mean_word_length': 5.578947368421052, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3154585', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1068, 'n_words': 288}