Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
emfy0 committed Oct 17, 2024
1 parent 5ffff4d commit 2978d7e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,18 @@ schema.with_context(five: 15).(nil)
# => Datacaster::ValidResult(nil)
```

Helper method `has_key?` is available, it can be used to search through existing context keys.

```ruby
schema =
Datacaster.schema do
check { context.has_key?(:five) }
end

schema.with_context(five: 15).(nil)
# => Datacaster::ValidResult(nil)
```

**Note**

`context` can be accesed only in casters' blocks. It can't be used in schema definition itself:
Expand Down

0 comments on commit 2978d7e

Please sign in to comment.