| 1 | #include "Validation.h" |
| 2 | |
| 3 | int checkArgsIs(const char* name, int expected, int got) |
| 4 | { |
| 5 | MAL_CHECK(got == expected, |
| 6 | "\"%s\" expects %d arg%s, %d supplied", |
| 7 | name, expected, PLURAL(expected), got); |
| 8 | return got; |
| 9 | } |
| 10 | |
| 11 | int checkArgsBetween(const char* name, int min, int max, int got) |
| 12 | { |
| 13 | MAL_CHECK((got >= min) && (got <= max), |
| 14 | "\"%s\" expects between %d and %d arg%s, %d supplied", |
| 15 | name, min, max, PLURAL(max), got); |
| 16 | return got; |
| 17 | } |
| 18 | |
| 19 | int checkArgsAtLeast(const char* name, int min, int got) |
| 20 | { |
| 21 | MAL_CHECK(got >= min, |
| 22 | "\"%s\" expects at least %d arg%s, %d supplied", |
| 23 | name, min, PLURAL(min), got); |
| 24 | return got; |
| 25 | } |
| 26 | |
| 27 | int checkArgsEven(const char* name, int got) |
| 28 | { |
| 29 | MAL_CHECK(got % 2 == 0, |
| 30 | "\"%s\" expects an even number of args, %d supplied", |
| 31 | name, got); |
| 32 | return got; |
| 33 | } |