| @@ 261-276 (lines=16) @@ | ||
| 258 | * @param $args |
|
| 259 | * @throws InvalidConditionException |
|
| 260 | */ |
|
| 261 | protected function validate($args) |
|
| 262 | { |
|
| 263 | $rules = array( |
|
| 264 | 'name' => 'required', |
|
| 265 | 'type' => 'required', |
|
| 266 | 'target' => 'required', |
|
| 267 | 'value' => 'required', |
|
| 268 | ); |
|
| 269 | ||
| 270 | $validator = CartConditionValidator::make($args, $rules); |
|
| 271 | ||
| 272 | if( $validator->fails() ) |
|
| 273 | { |
|
| 274 | throw new InvalidConditionException($validator->messages()->first()); |
|
| 275 | } |
|
| 276 | } |
|
| 277 | } |
|
| @@ 659-676 (lines=18) @@ | ||
| 656 | * @return array $item; |
|
| 657 | * @throws InvalidItemException |
|
| 658 | */ |
|
| 659 | protected function validate($item) |
|
| 660 | { |
|
| 661 | $rules = array( |
|
| 662 | 'id' => 'required', |
|
| 663 | 'price' => 'required|numeric', |
|
| 664 | 'quantity' => 'required|numeric|min:1', |
|
| 665 | 'name' => 'required', |
|
| 666 | ); |
|
| 667 | ||
| 668 | $validator = CartItemValidator::make($item, $rules); |
|
| 669 | ||
| 670 | if( $validator->fails() ) |
|
| 671 | { |
|
| 672 | throw new InvalidItemException($validator->messages()->first()); |
|
| 673 | } |
|
| 674 | ||
| 675 | return $item; |
|
| 676 | } |
|
| 677 | ||
| 678 | /** |
|
| 679 | * add row to cart collection |
|