@@ 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 | } |
@@ 627-644 (lines=18) @@ | ||
624 | * @return array $item; |
|
625 | * @throws InvalidItemException |
|
626 | */ |
|
627 | protected function validate($item) |
|
628 | { |
|
629 | $rules = array( |
|
630 | 'id' => 'required', |
|
631 | 'price' => 'required|numeric', |
|
632 | 'quantity' => 'required|numeric|min:1', |
|
633 | 'name' => 'required', |
|
634 | ); |
|
635 | ||
636 | $validator = CartItemValidator::make($item, $rules); |
|
637 | ||
638 | if ($validator->fails()) { |
|
639 | throw new InvalidItemException($validator->messages()->first()); |
|
640 | } |
|
641 | ||
642 | return $item; |
|
643 | } |
|
644 | ||
645 | /** |
|
646 | * add row to cart collection |
|
647 | * |