Sha256: d5af0da97a99f22370f915be9b79278129428f91e2d6aacd8886647769326bb3
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
# activemodel-ipaddr_validator [![Build Status](https://travis-ci.org/yuku-t/activemodel-ipaddr_validator.svg?branch=master)](https://travis-ci.org/yuku-t/activemodel-ipaddr_validator) [![Code Climate](https://codeclimate.com/github/yuku-t/activemodel-ipaddr_validator/badges/gpa.svg)](https://codeclimate.com/github/yuku-t/activemodel-ipaddr_validator) [![Coverage Status](https://coveralls.io/repos/yuku-t/activemodel-ipaddr_validator/badge.svg)](https://coveralls.io/r/yuku-t/activemodel-ipaddr_validator) [![Dependency Status](https://gemnasium.com/yuku-t/activemodel-ipaddr_validator.svg)](https://gemnasium.com/yuku-t/activemodel-ipaddr_validator) ## Usage Add to your Gemfile: ```rb gem 'activemodel-ipaddr_validator' ``` Run: ``` bundle install ``` Then add the following to your model: ```rb validates :my_ipaddr_attribute, ipaddr: true ``` ### Custom options Name | Value | Default | Description --------|---------|---------|------------------------------------- `ipv4` | Boolean | true | Accept IPv4. `ipv6` | Boolean | false | Accept IPv6. `array` | Boolean | false | Expect an array of strings. ```rb validates :ipv6s_attribute, ipaddr: { array: true, ipv4: false, ipv6: true } serialize :ipv6s_attribute, Array ``` ## Validation outside a model If you need to validate an IP outside a model, you can do that: ```rb IpaddrValidator.valid?(value, options) ```
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activemodel-ipaddr_validator-0.0.2 | README.md |