domainic-type 0.1.0.alpha.3.2.0 → 0.1.0.alpha.3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +66 -10
- data/docs/USAGE.md +732 -0
- data/lib/domainic/type/accessors.rb +3 -2
- data/lib/domainic/type/behavior/date_time_behavior.rb +117 -37
- data/lib/domainic/type/config/registry.yml +21 -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/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 +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5342f3d3bb47776a4cb27404a0a244d8e0d2761f14de0fc1efe0638ac354c387
|
4
|
+
data.tar.gz: e5c55975ec267fba4623239df150111b6bb13eda48448ff4e026007e50342578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1563338aa961165140ef8d72d22c04d9f46e5c08fd95c02b037d32b74f21570b136c7b07094093b4dd47c59b5be6b7cfaa003114ced0e4aad963a15305088e5
|
7
|
+
data.tar.gz: 01751a3ccf57ddea40d185aa6d04e12ea7a78bd94c0770aeb4af8dbd449d43ac0eec5eda64f91fe1828ff05ab0e2a53d8b24b78f4c13347c9fbaeae343be928b
|
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).
|