quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

Change the C++ Min and Max Value type to int64_t

Open Crayon2000 opened this issue 3 years ago • 0 comments

It makes more sense since the _integerType is also set to int64_t.

So in this generated code, we would now compare the int64_t value with *c.get_min_value() (also int64_t ):

inline void CheckConstraint(const std::string &  name, const ClassMemberConstraints & c, int64_t value) {
    if (c.get_min_value() != std::nullopt && value < *c.get_min_value()) {
        throw ValueTooLowException ("Value too low for " + name + " (" + std::to_string(value) + "<" + std::to_string(*c.get_min_value()) + ")");
    }

    if (c.get_max_value() != std::nullopt && value > *c.get_max_value()) {
        throw ValueTooHighException ("Value too high for " + name + " (" + std::to_string(value) + ">" + std::to_string(*c.get_max_value()) + ")");
    }
}

Crayon2000 avatar Mar 22 '22 18:03 Crayon2000