WebAPI节点,支持输入数据项的校验功能。用户仅需在Rule项中,配置校验表达式即可。
表达式必须返回一个字符串;为空时,生成验证通过;不为空时,验证失败,在界面显示该字符串。
校验规则格式,一般为:
条件?'':'不合法说明'
例如:
10 < val && val <100?'':'数值必须界于10~100之间'
条件为:10 < val && val <100,意为输出数值界于10-100之间。其中val代表输入的数据。
条件为真时,验证成功,返回空。
条件为假时,验证失败,返回字符串“数值必须界于10~100之间”。
也可简化为:
条件
例如:
10 < val && val <100
条件为:10 < val && val <100,意为输出数值界于10-100之间。其中val代表输入的数据。
条件为真时,验证成功,返回空。
条件为假时,验证失败,返回字符串“输入字符串不合规”。
例如:验证以逗号间隔的4个数字。
"DefaultValue": "-200,200,-200,200",
"Rule":"IsMatch(val,'^-?[1-9]\\d*,-?[1-9]\\d*,-?[1-9]\\d*,-?[1-9]\\d*$')",
可用函数:
Boolean fileExists(String)
Boolean IsMatch(string input, string pattern) #正则表达式
String ToString()
Int32 GetHashCode()
String urlEncode(String,Boolean)
String urlEncode(String)
String urlDecode(String)
String htmlEncode(String)
String htmlDecode(String)
Boolean ContainsXss(String)
String appSetting(String)
String indent()
String indents(Int32)
String space()
String spaces(Int32)
String newLine()
String newLines(Int32)
String newLine(String)
String append(String,String)
String appendLine(String)
String dateFormat(DateTime)
String dateFormat(DateTime,String)
String dateTimeFormat(DateTime)
String splitCase(String)
String humanize(String)
String titleCase(String)
String pascalCase(String)
String camelCase(String)
String snakeCase(String)
String kebabCase(String)
String textStyle(String,String)
String lower(String)
String upper(String)
String substring(String,Int32)
String substring(String,Int32,Int32)
String substringWithElipsis(String,Int32)
String substringWithElipsis(String,Int32,Int32)
String substringWithEllipsis(String,Int32)
String substringWithEllipsis(String,Int32,Int32)
String leftPart(String,String)
String rightPart(String,String)
String lastLeftPart(String,String)
String lastRightPart(String,String)
Int32 compareTo(String,String)
Boolean startsWith(String,String)
Boolean endsWith(String,String)
String replace(String,String,String)
String trimStart(String)
String trimEnd(String)
String trim(String)
String padLeft(String,Int32)
String padRight(String,Int32)
String addPath(String,String)
String repeating(Int32,String)
String repeat(String,Int32)
String escapeSingleQuotes(String)
String escapeDoubleQuotes(String)
String escapeBackticks(String)
String escapePrimeQuotes(String)
String escapeNewLines(String)
String generateSlug(String)
Boolean isBinary(String)
String contentType(String)
Double div(Double,Double)
Double divide(Double,Double)
Double pi()
Double e()
Double floor(Double)
Double ceiling(Double)
Double abs(Double)
Double acos(Double)
Double atan(Double)
Double atan2(Double,Double)
Double cos(Double)
Double exp(Double)
Double log(Double)
Double log(Double,Double)
Double log2(Double)
Double log10(Double)
Double pow(Double,Double)
Double round(Double)
Double round(Double,Int32)
Int32 sign(Double)
Double sin(Double)
Double sinh(Double)
Double sqrt(Double)
Double tan(Double)
Double tanh(Double)
Double truncate(Double)
Int32 intAdd(Int32,Int32)
Int32 intSub(Int32,Int32)
Int32 intMul(Int32,Int32)
Int32 intDiv(Int32,Int32)
Double doubleAdd(Double,Double)
Double doubleSub(Double,Double)
Double doubleMul(Double,Double)
Double doubleDiv(Double,Double)
DateTime date(Int32,Int32,Int32)
DateTime date(Int32,Int32,Int32,Int32,Int32,Int32)
Int32 AssertWithinMaxQuota(Int32)
String dirPath(String)
Boolean not(Boolean)
DateTime now()
DateTime utcNow()
DateTime addTicks(DateTime,Int32)
DateTime addMilliseconds(DateTime,Int32)
DateTime addSeconds(DateTime,Int32)
DateTime addMinutes(DateTime,Int32)
DateTime addHours(DateTime,Int32)
DateTime addDays(DateTime,Int32)
DateTime addMonths(DateTime,Int32)
DateTime addYears(DateTime,Int32)
Boolean isEven(Int32)
Boolean isOdd(Int32)
Boolean isZero(Double)
Boolean isPositive(Double)
Boolean isNegative(Double)
Boolean isNaN(Double)
Boolean isInfinity(Double)
String ToString()
Int32 GetHashCode()
String ToString()
Int32 GetHashCode()
网友评论