@@ 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 | } |
@@ 611-628 (lines=18) @@ | ||
608 | * @return array $item; |
|
609 | * @throws InvalidItemException |
|
610 | */ |
|
611 | protected function validate($item) |
|
612 | { |
|
613 | $rules = array( |
|
614 | 'id' => 'required', |
|
615 | 'price' => 'required|numeric', |
|
616 | 'quantity' => 'required|numeric|min:1', |
|
617 | 'name' => 'required', |
|
618 | ); |
|
619 | ||
620 | $validator = CartItemValidator::make($item, $rules); |
|
621 | ||
622 | if ($validator->fails()) { |
|
623 | throw new InvalidItemException($validator->messages()->first()); |
|
624 | } |
|
625 | ||
626 | return $item; |
|
627 | } |
|
628 | ||
629 | /** |
|
630 | * add row to cart collection |
|
631 | * |