dry-types 1.0.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +2 -5
  3. data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +10 -0
  4. data/.github/ISSUE_TEMPLATE/---bug-report.md +30 -0
  5. data/.github/ISSUE_TEMPLATE/---feature-request.md +18 -0
  6. data/.github/workflows/custom_ci.yml +76 -0
  7. data/.github/workflows/docsite.yml +34 -0
  8. data/.github/workflows/sync_configs.yml +34 -0
  9. data/.gitignore +1 -1
  10. data/.rspec +3 -1
  11. data/.rubocop.yml +92 -0
  12. data/CHANGELOG.md +124 -3
  13. data/CODE_OF_CONDUCT.md +13 -0
  14. data/CONTRIBUTING.md +2 -2
  15. data/Gemfile +14 -6
  16. data/LICENSE +17 -17
  17. data/README.md +3 -4
  18. data/Rakefile +2 -2
  19. data/benchmarks/hash_schemas.rb +8 -6
  20. data/benchmarks/lax_schema.rb +0 -1
  21. data/benchmarks/profile_invalid_input.rb +1 -1
  22. data/benchmarks/profile_lax_schema_valid.rb +1 -1
  23. data/benchmarks/profile_valid_input.rb +1 -1
  24. data/docsite/source/array-with-member.html.md +13 -0
  25. data/docsite/source/built-in-types.html.md +116 -0
  26. data/docsite/source/constraints.html.md +31 -0
  27. data/docsite/source/custom-types.html.md +93 -0
  28. data/docsite/source/default-values.html.md +91 -0
  29. data/docsite/source/enum.html.md +69 -0
  30. data/docsite/source/extensions.html.md +15 -0
  31. data/docsite/source/extensions/maybe.html.md +57 -0
  32. data/docsite/source/extensions/monads.html.md +61 -0
  33. data/docsite/source/getting-started.html.md +57 -0
  34. data/docsite/source/hash-schemas.html.md +169 -0
  35. data/docsite/source/index.html.md +156 -0
  36. data/docsite/source/map.html.md +17 -0
  37. data/docsite/source/optional-values.html.md +35 -0
  38. data/docsite/source/sum.html.md +21 -0
  39. data/dry-types.gemspec +19 -19
  40. data/lib/dry/types.rb +9 -4
  41. data/lib/dry/types/any.rb +2 -2
  42. data/lib/dry/types/array.rb +6 -0
  43. data/lib/dry/types/array/constructor.rb +32 -0
  44. data/lib/dry/types/array/member.rb +10 -3
  45. data/lib/dry/types/builder.rb +2 -2
  46. data/lib/dry/types/builder_methods.rb +37 -23
  47. data/lib/dry/types/coercions.rb +25 -6
  48. data/lib/dry/types/coercions/params.rb +5 -5
  49. data/lib/dry/types/compiler.rb +2 -2
  50. data/lib/dry/types/constrained.rb +7 -2
  51. data/lib/dry/types/constructor.rb +10 -42
  52. data/lib/dry/types/constructor/function.rb +5 -6
  53. data/lib/dry/types/core.rb +27 -8
  54. data/lib/dry/types/decorator.rb +3 -2
  55. data/lib/dry/types/default.rb +2 -2
  56. data/lib/dry/types/enum.rb +3 -2
  57. data/lib/dry/types/errors.rb +5 -5
  58. data/lib/dry/types/extensions.rb +4 -0
  59. data/lib/dry/types/extensions/maybe.rb +10 -2
  60. data/lib/dry/types/extensions/monads.rb +29 -0
  61. data/lib/dry/types/hash.rb +11 -12
  62. data/lib/dry/types/hash/constructor.rb +5 -5
  63. data/lib/dry/types/json.rb +4 -0
  64. data/lib/dry/types/lax.rb +5 -5
  65. data/lib/dry/types/map.rb +8 -4
  66. data/lib/dry/types/meta.rb +1 -1
  67. data/lib/dry/types/module.rb +6 -6
  68. data/lib/dry/types/nominal.rb +4 -5
  69. data/lib/dry/types/params.rb +9 -0
  70. data/lib/dry/types/predicate_inferrer.rb +197 -0
  71. data/lib/dry/types/predicate_registry.rb +34 -0
  72. data/lib/dry/types/primitive_inferrer.rb +97 -0
  73. data/lib/dry/types/printer.rb +17 -12
  74. data/lib/dry/types/result.rb +2 -2
  75. data/lib/dry/types/schema.rb +14 -20
  76. data/lib/dry/types/schema/key.rb +24 -2
  77. data/lib/dry/types/spec/types.rb +6 -7
  78. data/lib/dry/types/sum.rb +3 -3
  79. data/lib/dry/types/version.rb +1 -1
  80. metadata +59 -33
  81. data/.travis.yml +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bb3d91a31885a317b8fda3eef46f77b283abb3781c84124cc7ca0a5a2c30104
4
- data.tar.gz: 88cd356e7878080570e5fa659f1403e01d8bc8a9654b3c5cfaf568c851d8e848
3
+ metadata.gz: 2b3fc7a2d5685f6e867418934765d0e3a4ecfbc5b62385ee371a38e15c09e9b1
4
+ data.tar.gz: 07ef4d9b60132cf459fbf18709e44b275e23f94141a3dc975d2eb50e7ac500e8
5
5
  SHA512:
6
- metadata.gz: 536386eba753a58a499c473d7f9e54da2bccf8597d80e3e225a036fb37acd886e0e9f75ceff497e81e6cb9a47141c2fdf4753f2bd521bf5a53424f768fc0cf0d
7
- data.tar.gz: f74042df53c00159132ff2675206a393ca73a0d48ab84f7e6d58d56a51082e570932591279705ec993056b8e2720fd4572657b7bcb90596a16a7addaa7ac4bcf
6
+ metadata.gz: 1b82208815b88c0c3291b4bb6db0ddf781d2cd13fad10e98b265b79bf070a2099c5a010cb20a313f9f3833a6b6f6ce2839938a51c34d73a1eaa4eaf2952868af
7
+ data.tar.gz: cccb4e835c977bfa978e4fd7d9d253810e9c83b9e5b181bb44b544caff966bd71957c7d730de17f2d5081f05a0be527495bf16b6222bbbe3657fa897fc33e085
data/.codeclimate.yml CHANGED
@@ -1,9 +1,6 @@
1
- version: "2"
1
+ # this file is managed by dry-rb/devtools project
2
2
 
3
- prepare:
4
- fetch:
5
- - url: "https://raw.githubusercontent.com/dry-rb/devtools/master/.rubocop.yml"
6
- path: ".rubocop.yml"
3
+ version: "2"
7
4
 
8
5
  exclude_patterns:
9
6
  - "benchmarks/"
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: "⚠️ Please don't ask for support via issues"
3
+ about: See CONTRIBUTING.md for more information
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: "\U0001F41B Bug report"
3
+ about: See CONTRIBUTING.md for more information
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Before you submit this: WE ONLY ACCEPT BUG REPORTS AND FEATURE REQUESTS**
11
+
12
+ For more information see `CONTRIBUTING.md`.
13
+
14
+ **Describe the bug**
15
+
16
+ A clear and concise description of what the bug is.
17
+
18
+ **To Reproduce**
19
+
20
+ Provide detailed steps to reproduce, an executable script would be best.
21
+
22
+ **Expected behavior**
23
+
24
+ A clear and concise description of what you expected to happen.
25
+
26
+ **Your environment**
27
+
28
+ - Affects my production application: **YES/NO**
29
+ - Ruby version: ...
30
+ - OS: ...
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: "\U0001F6E0 Feature request"
3
+ about: See CONTRIBUTING.md for more information
4
+ title: ''
5
+ labels: feature
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ Summary of what the feature is supposed to do.
11
+
12
+ ## Examples
13
+
14
+ Code examples showing how the feature could be used.
15
+
16
+ ## Resources
17
+
18
+ Additional information, like a link to the discussion forum thread where the feature was discussed etc.
@@ -0,0 +1,76 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - .github/workflows/custom_ci.yml
7
+ - lib/**
8
+ - spec/**
9
+
10
+ jobs:
11
+ tests-mri:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ ruby: ["2.6.x", "2.5.x", "2.4.x"]
17
+ dry_logic_from_master: ["true", "false"]
18
+ include:
19
+ - ruby: "2.6.x"
20
+ dry_logic_from_master: "false"
21
+ coverage: "true"
22
+ steps:
23
+ - uses: actions/checkout@v1
24
+ - name: Set up Ruby
25
+ uses: actions/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{matrix.ruby}}
28
+ - name: Download test reporter
29
+ if: "matrix.coverage == 'true'"
30
+ run: |
31
+ mkdir -p tmp/
32
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
33
+ chmod +x ./tmp/cc-test-reporter
34
+ ./tmp/cc-test-reporter before-build
35
+ - name: Run all tests
36
+ env:
37
+ COVERAGE: ${{matrix.coverage}}
38
+ DRY_LOGIC_FROM_MASTER: ${{matrix.dry_logic_from_master}}
39
+ run: |
40
+ gem install bundler
41
+ bundle install --jobs 4 --retry 3 --without tools docs
42
+ bundle exec rake
43
+ - name: Send coverage results
44
+ if: "matrix.coverage == 'true'"
45
+ env:
46
+ CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
47
+ GIT_COMMIT_SHA: ${{github.sha}}
48
+ GIT_BRANCH: ${{github.ref}}
49
+ GIT_COMMITTED_AT: ${{github.event.head_commit.timestamp}}
50
+ run: |
51
+ GIT_BRANCH=`ruby -e "puts ENV['GITHUB_REF'].split('/', 3).last"` \
52
+ GIT_COMMITTED_AT=`ruby -r time -e "puts Time.iso8601(ENV['GIT_COMMITTED_AT']).to_i"` \
53
+ ./tmp/cc-test-reporter after-build
54
+
55
+ tests-others:
56
+ runs-on: ubuntu-latest
57
+ strategy:
58
+ fail-fast: false
59
+ matrix:
60
+ image: ["jruby:9.2.9", "ruby:rc"]
61
+ dry_logic_from_master: ["true", "false"]
62
+ container:
63
+ image: ${{matrix.image}}
64
+ steps:
65
+ - uses: actions/checkout@v1
66
+ - name: Install git
67
+ run: |
68
+ apt-get update
69
+ apt-get install -y --no-install-recommends git
70
+ - name: Run all tests
71
+ env:
72
+ DRY_LOGIC_FROM_MASTER: ${{matrix.dry_logic_from_master}}
73
+ run: |
74
+ gem install bundler
75
+ bundle install --jobs 4 --retry 3 --without tools docs
76
+ bundle exec rspec
@@ -0,0 +1,34 @@
1
+ # this file is managed by dry-rb/devtools project
2
+
3
+ name: docsite
4
+
5
+ on:
6
+ push:
7
+ paths:
8
+ - docsite/**
9
+ - .github/workflows/docsite.yml
10
+ branches:
11
+ - master
12
+ - release-**
13
+ tags:
14
+
15
+ jobs:
16
+ update-docs:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v1
20
+ - name: Set up Ruby
21
+ uses: actions/setup-ruby@v1
22
+ with:
23
+ ruby-version: "2.6.x"
24
+ - name: Install dependencies
25
+ run: |
26
+ gem install bundler
27
+ bundle install --jobs 4 --retry 3 --without benchmarks sql
28
+ - name: Symlink ossy
29
+ run: mkdir -p bin && ln -sf "$(bundle show ossy)/bin/ossy" bin/ossy
30
+ - name: Trigger dry-rb.org deploy
31
+ env:
32
+ GITHUB_LOGIN: dry-bot
33
+ GITHUB_TOKEN: ${{ secrets.GH_PAT }}
34
+ run: bin/ossy github workflow dry-rb/dry-rb.org ci
@@ -0,0 +1,34 @@
1
+ # this file is managed by dry-rb/devtools project
2
+
3
+ name: sync_configs
4
+
5
+ on:
6
+ repository_dispatch:
7
+
8
+ jobs:
9
+ sync-configs:
10
+ runs-on: ubuntu-latest
11
+ if: github.event.action == 'sync_configs'
12
+ steps:
13
+ - uses: actions/checkout@v1
14
+ - name: Update configuration files from devtools
15
+ env:
16
+ GITHUB_LOGIN: dry-bot
17
+ GITHUB_TOKEN: ${{ secrets.GH_PAT }}
18
+ run: |
19
+ git clone https://github.com/dry-rb/devtools.git tmp/devtools
20
+
21
+ if [ -f ".github/workflows/custom_ci.yml" ]; then
22
+ rsync -av --exclude '.github/workflows/ci.yml' tmp/devtools/shared/ . ;
23
+ else
24
+ rsync -av tmp/devtools/shared/ . ;
25
+ fi
26
+
27
+ git config --local user.email "dry-bot@dry-rb.org"
28
+ git config --local user.name "dry-bot"
29
+ git add -A
30
+ git commit -m "[devtools] config sync" || echo "nothing changed"
31
+ - name: Push changes
32
+ uses: ad-m/github-push-action@master
33
+ with:
34
+ github_token: ${{ secrets.GH_PAT }}
data/.gitignore CHANGED
@@ -8,4 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  log/
11
- .rubocop.yml
11
+
data/.rspec CHANGED
@@ -1,2 +1,4 @@
1
1
  --color
2
- --require ./spec/spec_helper
2
+ --require spec_helper
3
+ --order random
4
+
data/.rubocop.yml ADDED
@@ -0,0 +1,92 @@
1
+ # this file is managed by dry-rb/devtools project
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.4
5
+
6
+ Style/EachWithObject:
7
+ Enabled: false
8
+
9
+ Style/StringLiterals:
10
+ Enabled: true
11
+ EnforcedStyle: single_quotes
12
+
13
+ Style/Alias:
14
+ Enabled: false
15
+
16
+ Style/LambdaCall:
17
+ Enabled: false
18
+
19
+ Style/StabbyLambdaParentheses:
20
+ Enabled: false
21
+
22
+ Style/FormatString:
23
+ Enabled: false
24
+
25
+ Style/Documentation:
26
+ Enabled: false
27
+
28
+ Layout/SpaceInLambdaLiteral:
29
+ Enabled: false
30
+
31
+ Layout/MultilineMethodCallIndentation:
32
+ Enabled: true
33
+ EnforcedStyle: indented
34
+
35
+ Metrics/LineLength:
36
+ Max: 100
37
+
38
+ Metrics/MethodLength:
39
+ Max: 22
40
+
41
+ Metrics/ClassLength:
42
+ Max: 150
43
+
44
+ Metrics/AbcSize:
45
+ Max: 20
46
+
47
+ Metrics/BlockLength:
48
+ Enabled: false
49
+
50
+ Metrics/CyclomaticComplexity:
51
+ Enabled: true
52
+ Max: 10
53
+
54
+ Lint/BooleanSymbol:
55
+ Enabled: false
56
+
57
+ Style/AccessModifierDeclarations:
58
+ Enabled: false
59
+
60
+ Style/BlockDelimiters:
61
+ Enabled: false
62
+
63
+ Layout/IndentFirstArrayElement:
64
+ EnforcedStyle: consistent
65
+
66
+ Style/ClassAndModuleChildren:
67
+ Exclude:
68
+ - "spec/**/*_spec.rb"
69
+
70
+ Lint/HandleExceptions:
71
+ Exclude:
72
+ - "spec/spec_helper.rb"
73
+
74
+ Naming/FileName:
75
+ Exclude:
76
+ - "lib/dry-*.rb"
77
+
78
+ Style/SymbolArray:
79
+ Exclude:
80
+ - "spec/**/*_spec.rb"
81
+
82
+ Style/ConditionalAssignment:
83
+ Enabled: false
84
+
85
+ Naming/MethodName:
86
+ Enabled: false
87
+
88
+ Style/AsciiComments:
89
+ Enabled: false
90
+
91
+ Style/DateTime:
92
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,8 +1,121 @@
1
+ # 1.2.2 2019-12-14
2
+
3
+ ## Fixed
4
+
5
+ - `Types.Contructor` doesn't re-wrap class instances implementing type interface, this fixes some quirks in dry-struct (flash-gordon)
6
+
7
+ ## Changed
8
+
9
+ - Types now use immutable equalizers. This should improve performance in certain cases e.g. in ROM (flash-gordon)
10
+ - Attempting to use non-symbol keys in hash schemas raises an error. We always supported only symbols as keys but there was no check, now it'll throw an argument error. If you want to convert strings to symbols, use `Hash#with_key_transform` (flash-gordon)
11
+ - Params and JSON types accept Time/Date/Datetime instances and boolean values. This can be useful in tests but we discourage you from relying on this behavior in production code. For example, building structs with `Params` types is considered a smell. There are dedicated tools for coercion, namely dry-schema and dry-validation. Be responsible user of dry-types! ❤ (flash-gordon)
12
+
13
+ [Compare v1.2.1...v1.2.2](https://github.com/dry-rb/dry-types/compare/v1.2.1...v1.2.2)
14
+
15
+ # 1.2.1 2019-11-07
16
+
17
+ ## Fixed
18
+
19
+ - Fix keyword warnings reported by Ruby 2.7 (flash-gordon)
20
+ - Error type in failing case in `Array::Member` (esparta)
21
+
22
+ [Compare v1.2.0...v1.2.1](https://github.com/dry-rb/dry-types/compare/v1.2.0...v1.2.1)
23
+
24
+ # 1.2.0 2019-10-06
25
+
26
+ ## Changed
27
+
28
+ - `Dry::Types.[]` used to work with classes, now it's deprecated (flash-gordon)
29
+
30
+ ## Fixed
31
+
32
+ - Bug with using a `Bool`-named struct as a schema key (flash-gordon)
33
+ - A bunch of issues related to using `meta` on complex types (flash-gordon)
34
+ - `Types.Constructor(...)` returns a `Types::Array` as it should (flash-gordon)
35
+
36
+ ## Added
37
+
38
+ - `Optional::Params` types that coerce empty strings to `nil` (flash-gordon)
39
+ ```ruby
40
+ Dry::Types['optional.params.integer'].('') # => nil
41
+ Dry::Types['optional.params.integer'].('140') # => 140
42
+ Dry::Types['optional.params.integer'].('asd') # => exception!
43
+ ```
44
+ Keep in mind, `Dry::Types['optional.params.integer']` and `Dry::Types['params.integer'].optional` are not the same, the latter doesn't handle empty strings.
45
+ - Predicate inferrer was ported from dry-schema (authored by solnic)
46
+ ```ruby
47
+ require 'dry/types/predicate_inferrer'
48
+ Dry::Types::PredicateInferrer.new[Types::String]
49
+ # => [:str?]
50
+ Dry::Types::PredicateInferrer.new[Types::String | Types::Integer]
51
+ # => [[[:str?], [:int?]]]
52
+ ```
53
+ Note that the API of the predicate inferrer can change in the stable version, it's dictated by the needs of dry-schema so it should be considered as semi-stable. If you depend on it, write specs covering the desired behavior. Another option is copy-and-paste the whole thing to your project.
54
+ - Primitive inferrer was ported from dry-schema (authored by solnic)
55
+ ```ruby
56
+ require 'dry/types/primitive_inferrer'
57
+ Dry::Types::PrimitiveInferrer.new[Types::String]
58
+ # => [String]
59
+ Dry::Types::PrimitiveInferrer.new[Types::String | Types::Integer]
60
+ # => [String, Integer]
61
+ Dry::Types::PrimitiveInferrer.new[Types::String.optional]
62
+ # => [NilClass, String]
63
+ ```
64
+ The primitive inferrer should be stable by now, you can rely on it.
65
+ - The `monads` extension adds `Dry::Types::Result#to_monad`. This makes it compatible with do notation from dry-monads. Load it with `Dry::Types.load_extensions(:monads)` (skryukov)
66
+
67
+ ```ruby
68
+ Types = Dry.Types
69
+ Dry::Types.load_extensions(:monads)
70
+
71
+ class AddTen
72
+ include Dry::Monads[:result, :do]
73
+
74
+ def call(input)
75
+ integer = yield Types::Coercible::Integer.try(input)
76
+
77
+ Success(integer + 10)
78
+ end
79
+ end
80
+ ```
81
+
82
+ [Compare v1.1.1...v1.2.0](https://github.com/dry-rb/dry-types/compare/v1.1.1...v1.2.0)
83
+
84
+ # 1.1.1 2019-07-26
85
+
86
+ ## Fixed
87
+
88
+ - A bug where meta was lost for lax array types (flash-gordon)
89
+
90
+ [Compare v1.1.0...v1.1.1](https://github.com/dry-rb/dry-types/compare/v1.1.0...v1.1.1)
91
+
92
+ # 1.1.0 2019-07-02
93
+
94
+ ## Added
95
+
96
+ - New builder method `Interface` constructs a type which accepts objects that respond to the given methods (waiting-for-dev)
97
+ ```ruby
98
+ Types = Dry.Types()
99
+ Types::Callable = Types.Interface(:call)
100
+ Types::Callable.valid?(Object.new) # => false
101
+ Types::Callable.valid?(proc {}) # => true
102
+ ```
103
+ - New types: `coercible.symbol`, `params.symbol`, and `json.symbol`, all use `.to_sym` for coercion (waiting-for-dev)
104
+
105
+ ## Fixed
106
+
107
+ - Converting schema keys to maybe types (flash-gordon)
108
+ - Using `Schema#key` and `Array#member` on constuctors (flash-gordon)
109
+ - Using `meta(omittable: true)` within `transform_types` works again but produces a warning, please migrate to `.omittable` or `.required(false)` (flash-gordon)
110
+ - Bug with a constructror defined on top of enum (flash-gordon)
111
+
112
+ [Compare v1.0.1...v1.1.0](https://github.com/dry-rb/dry-types/compare/v1.0.1...v1.1.0)
113
+
1
114
  # 1.0.1 2019-06-04
2
115
 
3
116
  ## Added
4
117
 
5
- - In the case of failure the constructor block can now pass a different value (flash-gordon)
118
+ - In a case of failure the constructor block can now pass a different value (flash-gordon)
6
119
  ```ruby
7
120
  not_empty_string = Types::String.constructor do |value, &failure|
8
121
  value.strip.empty? ? failure.(nil) : value.strip
@@ -21,6 +134,7 @@
21
134
 
22
135
  - [BREAKING] Behavior of built-in constructor types was changed to be more strict. They will always raise an error on failed coercion (flash-gordon)
23
136
  Compare:
137
+
24
138
  ```ruby
25
139
  # 0.15.0
26
140
  Types::Params::Integer.('foo')
@@ -36,7 +150,9 @@
36
150
  ```ruby
37
151
  Types::Params::Integer.('foo') { :invalid } # => :invalid
38
152
  ```
153
+
39
154
  This makes work with coercions more straightforward and way faster.
155
+
40
156
  - [BREAKING] Safe types were renamed to Lax, this name better serves their purpose. The previous name is available but prints a warning (flash-gordon)
41
157
  - [BREAKING] Metadata is now pushed down to the decorated type. It is not likely you will notice a difference but this a breaking change that enables some use cases in rom related to the usage of default types in relations (flash-gordon)
42
158
  - Nominal types are now completely unconstrained. This fixes some inconsistencies when using them with constraints. `Nominal#try` will always return a successful result, for the previous behavior use `Nominal#try_coerce` or switch to strict types with passing a block to `#call` (flash-gordon)
@@ -159,6 +275,7 @@
159
275
  )
160
276
  ```
161
277
  - Key types have API for making keys omittable and back (flash-gordon)
278
+
162
279
  ```ruby
163
280
  # defining a base schema with optional keys
164
281
  lax_hash = Dry::Types['hash'].with_type_transform { |key| key.required(false) }
@@ -168,8 +285,10 @@
168
285
  # keys in user_schema are not required
169
286
  user_schema = lax_hash.schema(name: 'string', age: 'integer')
170
287
  ```
288
+
171
289
  - `Type#optional?` now recognizes more cases where `nil` is an allowed value (flash-gordon)
172
290
  - `Constructor#{prepend,append}` with `<<` and `>>` as aliases. `Constructor#append` works the same way `Constructor#constrcutor` does. `Constuctor#prepend` chains functions in the reverse order, see examples (flash-gordon)
291
+
173
292
  ```ruby
174
293
  to_int = Types::Coercible::Integer
175
294
  inc = to_int.append { |x| x + 2 }
@@ -178,6 +297,7 @@
178
297
  inc = to_int.prepend { |x| x + "2" }
179
298
  inc.("1") # => "1" -> "12" -> 12
180
299
  ```
300
+
181
301
  - Partial schema application for cases when you want to validate only a subset of keys (flash-gordon)
182
302
  This is useful when you want to update a key or two in an already-validated hash. A perfect example is `Dry::Struct#new` where this feature is now used.
183
303
  ```ruby
@@ -189,14 +309,15 @@
189
309
 
190
310
  ## Fixed
191
311
 
192
- * `Hash::Map` now behaves as a constrained type if its values are constrained (flash-gordon)
193
- * `coercible.integer` now doesn't blow up on invalid strings (exterm)
312
+ - `Hash::Map` now behaves as a constrained type if its values are constrained (flash-gordon)
313
+ - `coercible.integer` now doesn't blow up on invalid strings (exterm)
194
314
 
195
315
  [Compare v0.14.0...v0.15.0](https://github.com/dry-rb/dry-types/compare/v0.14.0...v0.15.0)
196
316
 
197
317
  # v0.14.1 2019-03-25
198
318
 
199
319
  ## Fixed
320
+
200
321
  - `coercible.integer` now doesn't blow up on invalid strings (exterm)
201
322
 
202
323
  [Compare v0.14.0...v0.14.1](https://github.com/dry-rb/dry-types/compare/v0.14.0...v0.14.1)