README.md in truemail-1.5.1 vs README.md in truemail-1.6.0

- old
+ new

@@ -1,8 +1,8 @@ # <img src='https://repository-images.githubusercontent.com/173723932/6dffee00-e88e-11e9-94b6-c97aacc0df00' height='250' alt='Truemail - configurable framework agnostic plain Ruby email validator' /> -[![Maintainability](https://api.codeclimate.com/v1/badges/657aa241399927dcd2e2/maintainability)](https://codeclimate.com/github/rubygarage/truemail/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/657aa241399927dcd2e2/test_coverage)](https://codeclimate.com/github/rubygarage/truemail/test_coverage) [![CircleCI](https://circleci.com/gh/rubygarage/truemail/tree/master.svg?style=svg)](https://circleci.com/gh/rubygarage/truemail/tree/master) [![Gem Version](https://badge.fury.io/rb/truemail.svg)](https://badge.fury.io/rb/truemail) [![Downloads](https://img.shields.io/gem/dt/truemail.svg?colorA=004d99&colorB=0073e6)](https://rubygems.org/gems/truemail) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md) +[![Maintainability](https://api.codeclimate.com/v1/badges/657aa241399927dcd2e2/maintainability)](https://codeclimate.com/github/rubygarage/truemail/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/657aa241399927dcd2e2/test_coverage)](https://codeclimate.com/github/rubygarage/truemail/test_coverage) [![CircleCI](https://circleci.com/gh/rubygarage/truemail/tree/master.svg?style=svg)](https://circleci.com/gh/rubygarage/truemail/tree/master) [![Gem Version](https://badge.fury.io/rb/truemail.svg)](https://badge.fury.io/rb/truemail) [![Downloads](https://img.shields.io/gem/dt/truemail.svg?colorA=004d99&colorB=0073e6)](https://rubygems.org/gems/truemail) [![Gitter](https://badges.gitter.im/truemail-rb/community.svg)](https://gitter.im/truemail-rb/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md) Configurable framework agnostic plain Ruby email validator. Verify email via Regex, DNS and SMTP. Be sure that email address valid and exists. ## Table of Contents @@ -34,10 +34,11 @@ - [JSON serializer](#json-serializer) - [Host audit features](#host-audit-features) - [PTR audit](#ptr-audit) - [Truemail helpers](#truemail-helpers) - [.valid?](#valid) + - [#as_json](#as_json) - [Test environment](#test-environment) - [Truemail family](#truemail-family) - [Contributing](#contributing) - [License](#license) - [Code of Conduct](#code-of-conduct) @@ -926,15 +927,54 @@ ### Truemail helpers #### .valid? -You can use the ```.valid?``` helper for quick validation of email address. It returns a boolean: +You can use the `.valid?` helper for quick validation of email address. It returns a boolean: ```ruby # It is shortcut for Truemail.validate('email@example.com').result.valid? Truemail.valid?('email@example.com') => true +``` + +#### #as_json + +You can use `#as_json` helper for represent `Truemail::Validator` instance as json. Under the hood it uses internal json serializer [`Truemail::Log::Serializer::Json`](#json-serializer): + +```ruby +Truemail.validate('nonexistent_email@bestweb.com.ua').as_json + +=> +# Serialized Truemail::Validator instance +{ + "date": "2020-02-01 10:00:00 +0200", + "email": "nonexistent_email@bestweb.com.ua", + "validation_type": "smtp", + "success": false, + "errors": { + "smtp": "smtp error" + }, + "smtp_debug": [ + { + "mail_host": "213.180.193.89", + "port_opened": true, + "connection": true, + "errors": { + "rcptto": "550 5.7.1 No such user!\n" + } + } + ], + "configuration": { + "validation_type_by_domain": null, + "whitelist_validation": false, + "whitelisted_domains": null, + "blacklisted_domains": null, + "smtp_safe_check": false, + "email_pattern": "default gem value", + "smtp_error_body_pattern": "default gem value" + } +} ``` ### Test environment You can stub out that validation for your test environment. Just add RSpec before action: