README_V3.md in schemacop-3.0.12 vs README_V3.md in schemacop-3.0.13
- old
+ new
@@ -231,12 +231,12 @@
* `email`
Validates for a valid email address. There is no casting involved since email
addresses do not have their own ruby type.
* `boolean`
- The string must be either `true` or `false`. This value will be casted to
- Ruby's `TrueClass` or `FalseClass`.
+ The string must be either `true`, `false`, `0` or `1`. This value will be
+ casted to Ruby's `TrueClass` or `FalseClass`.
* `binary`
The string is expected to contain binary contents. No casting or additional
validation is performed.
@@ -499,12 +499,13 @@
The boolean type is used to validate Ruby booleans, i.e. the `TrueClass` and `FalseClass`
#### Options
* `cast_str`
- When set to `true`, this node also accepts strings that can be casted to a boolean, i.e.
- the values `'true'` and `'false'`. Blank strings will be treated equally as `nil`.
+ When set to `true`, this node also accepts strings that can be casted to a
+ boolean, namely the values `'true'`, `'false'`, `'1'` and `'0'`. Blank strings
+ will be treated equally as `nil`.
#### Examples
```ruby
# Validates that the input is a boolean
@@ -512,9 +513,14 @@
schema.validate!(true) # => true
schema.validate!(false) # => false
schema.validate!(:false) # => Schemacop::Exceptions::ValidationError: /: Invalid type, got type "Symbol", expected "boolean".
schema.validate!('false') # => Schemacop::Exceptions::ValidationError: /: Invalid type, got type "String", expected "boolean".
schema.validate!(1234) # => Schemacop::Exceptions::ValidationError: /: Invalid type, got type "Integer", expected "boolean".
+
+schema.validate!('0', cast_str: true) # => false
+schema.validate!('1', cast_str: true) # => true
+schema.validate!('false', cast_str: true) # => false
+schema.validate!('true', cast_str: true) # => true
```
With `cast_str` enabled:
```ruby