#include "JsonLogic.h"

namespace json_logic
{
    Json JsonLogic::operation_numeric_multiplication(JsonArrayView values, JsonView data) const
    {
        if (values.size() < 2)
            return Fail(__FUNCTION__, "Expected 2 or more arguments, but received " +
                                          std::to_string(values.size()));

        double result = 1;
        for (JsonView value : values)
        {
            const Json number = CastToNumber(ApplyInternal(value, data));
            if (HasError()) return Json{};
            result *= ToDouble(number);
        }
        return MakeNumber(result);
    }
}
