@@ 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 |
@@ 697-713 (lines=17) @@ | ||
694 | * @return array $item; |
|
695 | * @throws InvalidItemException |
|
696 | */ |
|
697 | protected function validate($item) |
|
698 | { |
|
699 | $rules = array( |
|
700 | 'id' => 'required', |
|
701 | 'price' => 'required|numeric', |
|
702 | 'quantity' => 'required|numeric|min:0.1', |
|
703 | 'name' => 'required', |
|
704 | ); |
|
705 | ||
706 | $validator = CartItemValidator::make($item, $rules); |
|
707 | ||
708 | if ($validator->fails()) { |
|
709 | throw new InvalidItemException($validator->messages()->first()); |
|
710 | } |
|
711 | ||
712 | return $item; |
|
713 | } |
|
714 | ||
715 | /** |
|
716 | * add row to cart collection |