@@ 620-637 (lines=18) @@ | ||
617 | * @return array $item; |
|
618 | * @throws InvalidItemException |
|
619 | */ |
|
620 | protected function validate($item) |
|
621 | { |
|
622 | $rules = array( |
|
623 | 'id' => 'required', |
|
624 | 'price' => 'required|numeric', |
|
625 | 'quantity' => 'required|numeric|min:1', |
|
626 | 'name' => 'required', |
|
627 | ); |
|
628 | ||
629 | $validator = CartItemValidator::make($item, $rules); |
|
630 | ||
631 | if( $validator->fails() ) |
|
632 | { |
|
633 | throw new InvalidItemException($validator->messages()->first()); |
|
634 | } |
|
635 | ||
636 | return $item; |
|
637 | } |
|
638 | ||
639 | /** |
|
640 | * add row to cart collection |
@@ 249-264 (lines=16) @@ | ||
246 | * @param $args |
|
247 | * @throws InvalidConditionException |
|
248 | */ |
|
249 | protected function validate($args) |
|
250 | { |
|
251 | $rules = array( |
|
252 | 'name' => 'required', |
|
253 | 'type' => 'required', |
|
254 | 'target' => 'required', |
|
255 | 'value' => 'required', |
|
256 | ); |
|
257 | ||
258 | $validator = CartConditionValidator::make($args, $rules); |
|
259 | ||
260 | if( $validator->fails() ) |
|
261 | { |
|
262 | throw new InvalidConditionException($validator->messages()->first()); |
|
263 | } |
|
264 | } |
|
265 | } |