| 906 | } |
| 907 | |
| 908 | void validate(const json::json_pointer &ptr, const json &instance, json_patch &, error_handler &e) const override |
| 909 | { |
| 910 | T value = instance; // conversion of json to value_type |
| 911 | |
| 912 | std::ostringstream oss; |
| 913 | |
| 914 | if (multipleOf_.first && value != 0) // zero is multiple of everything |
| 915 | if (violates_multiple_of(value)) |
| 916 | oss << "instance is not a multiple of " << json(multipleOf_.second); |
| 917 | |
| 918 | if (maximum_.first) { |
| 919 | if (exclusiveMaximum_ && value >= maximum_.second) |
| 920 | oss << "instance exceeds or equals maximum of " << json(maximum_.second); |
| 921 | else if (value > maximum_.second) |
| 922 | oss << "instance exceeds maximum of " << json(maximum_.second); |
| 923 | } |
| 924 | |
| 925 | if (minimum_.first) { |
| 926 | if (exclusiveMinimum_ && value <= minimum_.second) |
| 927 | oss << "instance is below or equals minimum of " << json(minimum_.second); |
| 928 | else if (value < minimum_.second) |
| 929 | oss << "instance is below minimum of " << json(minimum_.second); |
| 930 | } |
| 931 | |
| 932 | oss.seekp(0, std::ios::end); |
| 933 | auto size = oss.tellp(); |
| 934 | if (size != 0) { |
| 935 | oss.seekp(0, std::ios::beg); |
| 936 | e.error(ptr, instance, oss.str()); |
| 937 | } |
| 938 | } |
| 939 | |
| 940 | public: |
| 941 | numeric(const json &sch, root_schema *root, std::set<std::string> &kw) |