README.md in action_logic-0.2.1 vs README.md in action_logic-0.2.2
- old
+ new
@@ -587,11 +587,11 @@
def call
end
end
-ActionTaskExample.execute # ~> [:required_attribute1] (ActionLogic::MissingAttributeError)
+ActionTaskExample.execute # ~> context: ActionTaskExample message: [:required_attribute1] (ActionLogic::MissingAttributeError)
```
Attribute validations are defined in the same way regardless of the timing of the validation ([before](#before-validations), [after](#after-validations) or
[around](#around-validations)). Please refer to the relevant sections for examples of their usage.
@@ -655,11 +655,11 @@
def call
context.integer_test = 1.0
end
end
-ActionTaskExample.execute # ~> ["Attribute: integer_test with value: 1.0 was expected to be of type Fixnum but is Float"] (ActionLogic::AttributeTypeError)
+ActionTaskExample.execute # ~> context: ActionTaskExample message: Attribute: integer_test with value: 1.0 was expected to be of type Fixnum but is Float (ActionLogic::AttributeTypeError)
```
In addition to the above default types it is possible to also validate against user defined types.
### Custom Type Validations
@@ -707,11 +707,11 @@
def call
context.example_attribute = OtherClass.new
end
end
-ActionTaskExample.execute # ~> ["Attribute: example_attribute with value: #<OtherClass:0x007fb5ca04edb8> was expected to be of type ExampleClass but is OtherClass"] (ActionLogic::AttributeTypeError)
+ActionTaskExample.execute # ~> context: ActionTaskExample message: Attribute: example_attribute with value: #<OtherClass:0x007fb5ca04edb8> was expected to be of type ExampleClass but is OtherClass (ActionLogic::AttributeTypeError)
```
Attribute and type validations are very helpful, but in some situations this is not enough. Additionally, `ActionLogic` provides presence validation so you can also verify that
a given attribute on a context not only has the correct type, but also has a value that is considered `present`.
@@ -749,11 +749,11 @@
def call
end
end
-ActionTaskExample.execute(:example_attribute => nil) # ~> ["Attribute: example_attribute is missing value in context but presence validation was specified"] (ActionLogic::PresenceError)
+ActionTaskExample.execute(:example_attribute => nil) # ~> context: ActionTaskExample message: Attribute: example_attribute is missing value in context but presence validation was specified (ActionLogic::PresenceError)
```
### Custom Presence Validations
Sometimes when wanting to validate presence of an attribute with an aggregate type (like `Array` or `Hash`), we may want to validate that such a type is not empty. If
@@ -790,10 +790,10 @@
def call
end
end
-ActionTaskExample.execute(:example_attribute => []) # ~> ["Attribute: example_attribute is missing value in context but custom presence validation was specified"] (ActionLogic::PresenceError)
+ActionTaskExample.execute(:example_attribute => []) # ~> context: ActionTaskExample message: Attribute: example_attribute is missing value in context but custom presence validation was specified (ActionLogic::PresenceError)
```
In the above example, we have failed to pass the presence validation for `example_attribute` because the value of `example_attribute` is an empty array. When
the custom presence validation lambda is called, the lambda returns `false` and the `ActionLogic::PresenceError` is thrown, with an error message indicating
the attribute that failed the presence validation while also indicating that a custom presence validation was specified.