@@ 262-276 (lines=15) @@ | ||
259 | * @param $args |
|
260 | * @throws InvalidConditionException |
|
261 | */ |
|
262 | protected function validate($args) |
|
263 | { |
|
264 | $rules = array( |
|
265 | 'name' => 'required', |
|
266 | 'type' => '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 | } |
|
278 |
@@ 688-704 (lines=17) @@ | ||
685 | * @return array $item; |
|
686 | * @throws InvalidItemException |
|
687 | */ |
|
688 | protected function validate($item) |
|
689 | { |
|
690 | $rules = array( |
|
691 | 'id' => 'required', |
|
692 | 'price' => 'required|numeric', |
|
693 | 'quantity' => 'required|numeric|min:1', |
|
694 | 'name' => 'required', |
|
695 | ); |
|
696 | ||
697 | $validator = CartItemValidator::make($item, $rules); |
|
698 | ||
699 | if ($validator->fails()) { |
|
700 | throw new InvalidItemException($validator->messages()->first()); |
|
701 | } |
|
702 | ||
703 | return $item; |
|
704 | } |
|
705 | ||
706 | /** |
|
707 | * add row to cart collection |