pattern和patternProperties关键字都可以使用正则表达式。
正则表达式的语法是从JavaScript语法(Ecma 262)演变过来。当然,并没有完整的支持所有语法。
^: $: (...): |: [abc]: [a-z]: [^abc]: [^a-z]: +: *: ?: +?、*?、??: {x}: {x,y}: {x,}: {x}?、{x,y}?、{x,}?: // a schema
{
"type": "string",
"pattern": "^(\+?86)?1(3|5|7|8)\D{9}$"
}
"13512341234" // success
"+8617012341234" // success
"010-12341234" // failure