File: README.md

package info (click to toggle)
ruby-axiom-types 0.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid, stretch
  • size: 540 kB
  • ctags: 136
  • sloc: ruby: 1,901; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 1,307 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# axiom-types

Define types with optional constraints for use within axiom and other libraries.

[![Gem Version](https://badge.fury.io/rb/axiom-types.png)][gem]
[![Build Status](https://secure.travis-ci.org/dkubb/axiom-types.png?branch=master)][travis]
[![Dependency Status](https://gemnasium.com/dkubb/axiom-types.png)][gemnasium]
[![Code Climate](https://codeclimate.com/github/dkubb/axiom-types.png)][codeclimate]
[![Coverage Status](https://coveralls.io/repos/dkubb/axiom-types/badge.png?branch=master)][coveralls]

[gem]: https://rubygems.org/gems/axiom-types
[travis]: https://travis-ci.org/dkubb/axiom-types
[gemnasium]: https://gemnasium.com/dkubb/axiom-types
[codeclimate]: https://codeclimate.com/github/dkubb/axiom-types
[coveralls]: https://coveralls.io/r/dkubb/axiom-types

## Examples

```ruby
# Setup constraints for all defined types
Axiom::Types.finalize

# Create Name subtype
Name = Axiom::Types::String.new do
  minimum_length 1
  maximum_length 30
end

# Test if the string is a member of the type
Name.include?('a')       # => true
Name.include?('a' * 30)  # => true
Name.include?('')        # => false
Name.include?('a' * 31)  # => false
```

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for details.

## Copyright

Copyright © 2013 Dan Kubb. See LICENSE for details.