4 if (value.length() == 0) {
5 return name +
" cannot be empty";
7 for (
unsigned int i = 0;
i < value.length();
i++) {
8 if (!isdigit(value.charAt(
i))) {
9 return name +
" must be a positive integer";
16 if (value.length() == 0) {
17 return name +
" cannot be empty";
20 bool decimal_point =
false;
21 bool exponent =
false;
22 bool digit_seen =
false;
23 bool digit_after_exp =
true;
25 for (
unsigned int i = 0;
i < value.length();
i++) {
26 char c = value.charAt(
i);
29 if (
i == 0 && (c ==
'-' || c ==
'+'))
continue;
34 if (exponent) digit_after_exp =
true;
39 if (c ==
'.' && !decimal_point && !exponent) {
45 if ((c ==
'e' || c ==
'E') && !exponent && digit_seen) {
47 digit_after_exp =
false;
50 if (
i + 1 < value.length() &&
51 (value.charAt(
i + 1) ==
'+' || value.charAt(
i + 1) ==
'-')) {
58 return name +
" must be a valid number";
62 if (!digit_seen || !digit_after_exp) {
63 return name +
" must be a valid number";
70 if (value.length() == 0) {
71 return "API Endpoint URL cannot be empty";
73 if (!value.startsWith(
"http://") && !value.startsWith(
"https://")) {
74 return "API Endpoint URL must start with http:// or https://";
String validateFloat(const String &value, const String &name)
Validate a string as a floating-point number.
String validateUInt(const String &value, const String &name)
Validate a string as an unsigned integer.
String validateURL(const String &value)
Validate a string as a URL.