@@ 276-290 (lines=15) @@ | ||
273 | * @param $args |
|
274 | * @throws InvalidConditionException |
|
275 | */ |
|
276 | protected function validate($args) |
|
277 | { |
|
278 | $rules = array( |
|
279 | 'name' => 'required', |
|
280 | 'type' => 'required', |
|
281 | 'value' => 'required', |
|
282 | ); |
|
283 | ||
284 | $validator = CartConditionValidator::make($args, $rules); |
|
285 | ||
286 | if( $validator->fails() ) |
|
287 | { |
|
288 | throw new InvalidConditionException($validator->messages()->first()); |
|
289 | } |
|
290 | } |
|
291 | } |
|
292 |
@@ 718-734 (lines=17) @@ | ||
715 | * @return array $item; |
|
716 | * @throws InvalidItemException |
|
717 | */ |
|
718 | protected function validate($item) |
|
719 | { |
|
720 | $rules = array( |
|
721 | 'id' => 'required', |
|
722 | 'price' => 'required|numeric', |
|
723 | 'quantity' => 'required|numeric|min:1', |
|
724 | 'name' => 'required', |
|
725 | ); |
|
726 | ||
727 | $validator = CartItemValidator::make($item, $rules); |
|
728 | ||
729 | if ($validator->fails()) { |
|
730 | throw new InvalidItemException($validator->messages()->first()); |
|
731 | } |
|
732 | ||
733 | return $item; |
|
734 | } |
|
735 | ||
736 | /** |
|
737 | * add row to cart collection |