domainic-type 0.1.0.alpha.3.2.0 → 0.1.0.alpha.3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +11 -0
- data/README.md +66 -10
- data/docs/USAGE.md +787 -0
- data/lib/domainic/type/accessors.rb +3 -2
- data/lib/domainic/type/behavior/date_time_behavior.rb +121 -37
- data/lib/domainic/type/behavior.rb +16 -0
- data/lib/domainic/type/config/registry.yml +24 -0
- data/lib/domainic/type/constraint/constraints/nor_constraint.rb +1 -1
- data/lib/domainic/type/constraint/constraints/predicate_constraint.rb +76 -0
- data/lib/domainic/type/definitions.rb +212 -0
- data/lib/domainic/type/types/core/complex_type.rb +122 -0
- data/lib/domainic/type/types/core/range_type.rb +47 -0
- data/lib/domainic/type/types/core/rational_type.rb +38 -0
- data/lib/domainic/type/types/core_extended/big_decimal_type.rb +34 -0
- data/lib/domainic/type/types/core_extended/set_type.rb +34 -0
- data/lib/domainic/type/types/datetime/date_time_string_type.rb +156 -0
- data/lib/domainic/type/types/datetime/timestamp_type.rb +50 -0
- data/sig/domainic/type/accessors.rbs +2 -2
- data/sig/domainic/type/behavior/date_time_behavior.rbs +35 -23
- data/sig/domainic/type/behavior.rbs +9 -0
- data/sig/domainic/type/constraint/constraints/predicate_constraint.rbs +56 -0
- data/sig/domainic/type/definitions.rbs +165 -0
- data/sig/domainic/type/types/core/complex_type.rbs +96 -0
- data/sig/domainic/type/types/core/range_type.rbs +41 -0
- data/sig/domainic/type/types/core/rational_type.rbs +32 -0
- data/sig/domainic/type/types/core_extended/big_decimal_type.rbs +27 -0
- data/sig/domainic/type/types/core_extended/set_type.rbs +27 -0
- data/sig/domainic/type/types/datetime/date_time_string_type.rbs +124 -0
- data/sig/domainic/type/types/datetime/timestamp_type.rbs +44 -0
- metadata +25 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e864e12054b6928f12f7465eace3657aaa736e264a1655e7838ec4f2e658ebed
|
4
|
+
data.tar.gz: ac7c71c1bd2c2f992bb6aca1306291838a4b7eabc77326130db553de8a9dc18f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6029d7d12cb562dd7f2688472f0da97bcb548c544f163cf5215736d82ee0927e6f2c4ff87cc0d1818eefe722d10ac0ee2dd4ebccabff45412793340928e63cb8
|
7
|
+
data.tar.gz: 7ba6d7e41e431f2dd401bffecd60701a9dfeab35eeea3bef9085e97941d1b8327ddfd7cbe5febc577a0e1b3cce49147f6b686b56f1f6251257836d58327d198d
|
data/.yardopts
ADDED
data/README.md
CHANGED
@@ -2,30 +2,86 @@
|
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/domainic-type)
|
4
4
|
[](./LICENSE)
|
5
|
-
[](https://rubydoc.info/gems/domainic-type/0.1.0)
|
6
|
+
[](https://github.com/domainic/domainic/issues?q=state%3Aopen%20label%3Adomainic-type%20)
|
6
7
|
|
7
8
|
> [!IMPORTANT]
|
8
9
|
> We're running an experiment with Domainic::Type! Help us explore flexible type validation in Ruby by trying our
|
9
|
-
> [alpha release](
|
10
|
-
> the future of domain-driven design in Ruby.
|
10
|
+
> [alpha release](https://github.com/domainic/domainic/wiki/experiments-domainic-type-alpha-3). Your feedback is
|
11
|
+
> invaluable for shaping the future of domain-driven design in Ruby.
|
11
12
|
|
12
|
-
A flexible type validation system for Ruby
|
13
|
+
A flexible type validation system for Ruby that brings the power of composable constraints and crystal-clear error
|
14
|
+
messages to your domain models. Domainic::Type provides a rich set of built-in types that know how to validate
|
15
|
+
themselves, intelligently handle various formats, and tell you exactly what's wrong when validation fails.
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
This is particularly useful when building domain-driven applications, where strong type validation and clear error
|
18
|
+
handling are essential. Instead of writing repetitive validation code and complex error messages, let Domainic::Type
|
19
|
+
bring type safety to your Ruby code in a way that feels natural and expressive.
|
20
|
+
|
21
|
+
## Quick Start
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'domainic/type/definitions'
|
25
|
+
include Domainic::Type::Definitions
|
26
|
+
|
27
|
+
# Type validation with clear error messages
|
28
|
+
username = _String
|
29
|
+
.being_lowercase
|
30
|
+
.being_alphanumeric
|
31
|
+
.having_size_between(3, 20)
|
32
|
+
|
33
|
+
username.validate!("ABC123")
|
34
|
+
# => TypeError: Expected String(being lowercase), got String(not lowercase)
|
35
|
+
|
36
|
+
# Rich collection validation
|
37
|
+
admin_list = _Array
|
38
|
+
.of(_String)
|
39
|
+
.being_distinct
|
40
|
+
.being_ordered
|
41
|
+
.excluding("root")
|
42
|
+
|
43
|
+
admin_list.validate!(["admin", "admin", "user"])
|
44
|
+
# => TypeError: Expected Array(being distinct), got Array(containing duplicates)
|
45
|
+
|
46
|
+
# Strong type constraints
|
47
|
+
config = _Hash
|
48
|
+
.of(_Symbol => _String)
|
49
|
+
.containing_keys(:host, :port)
|
50
|
+
|
51
|
+
config.validate!({ host: 123 })
|
52
|
+
# => TypeError: Expected Hash(having values of String), got Hash(having values of Integer)
|
53
|
+
```
|
18
54
|
|
19
55
|
## Installation
|
20
56
|
|
21
57
|
Add this line to your application's Gemfile:
|
22
58
|
|
23
59
|
```ruby
|
24
|
-
gem 'domainic-type'
|
60
|
+
gem 'domainic-type'
|
25
61
|
```
|
26
62
|
|
27
63
|
Or install it yourself as:
|
28
64
|
|
29
65
|
```bash
|
30
|
-
gem install domainic-type
|
66
|
+
gem install domainic-type
|
31
67
|
```
|
68
|
+
|
69
|
+
## Documentation
|
70
|
+
|
71
|
+
For detailed usage instructions and examples, see [USAGE.md](./docs/USAGE.md).
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
We welcome contributions! Please see our
|
76
|
+
[Contributing Guidelines](https://github.com/domainic/domainic/wiki/CONTRIBUTING) for:
|
77
|
+
|
78
|
+
* Development setup and workflow
|
79
|
+
* Code style and documentation standards
|
80
|
+
* Testing requirements
|
81
|
+
* Pull request process
|
82
|
+
|
83
|
+
Before contributing, please review our [Code of Conduct](https://github.com/domainic/domainic/wiki/CODE_OF_CONDUCT).
|
84
|
+
|
85
|
+
## License
|
86
|
+
|
87
|
+
The gem is available as open source under the terms of the [MIT License](./LICENSE).
|