简体   繁体   English

cvc-pattern-valid:相对于模式,值不是 facet-valid

[英]cvc-pattern-valid: Value is not facet-valid with respect to pattern

Here is the entire error:这是整个错误:

cvc-pattern-valid: Value '03151364512' is not facet-valid with respect to pattern '((((\+011)|(011))[-]?)?(599)((416)|(717)|(318))[0-9]{4})|(((085)|(088))[-]?[0-9]{7})([,][1-9][0-9]{1,8})?|((((\+31)|(0)|(0031))[1-9][0-9]{2})[-]?([1-9][0-9]{5}))([,][1-9][0-9]{1,8})?|((((\+31)|(0)|(0031))[1-9][0-9])[-]?([1-9][0-9]{6}))([,][1-9][0-9]{1,8})?|(((14)[-]?)(0)([1-9][0-9]{1,2}))|((((\+31)|(0)|(0031))6){1}[-]?[1-9]{1}[0-9]{7})|\+(1\d{4,14}|2[078]\d{3,13}|3[0-469]\d{3,13}|4[013-9]\d{3,13}|5[1-9]\d{3,13}|6[0-6]\d{3,13}|7\d{4,14}|8[1-469]\d{3,13}|9[0-58]\d{3,13}|[2-9]\d{4,14})'

Every online checker I've used says this value should be valid.我用过的每个在线检查器都说这个值应该是有效的。 Any ideas?有任何想法吗?

XSD patterns should match the entire string. XSD 模式应该匹配整个字符串。

So, the pattern does not match 03151364512 as expected since the last 2 is not matched .因此,该模式与预期的03151364512不匹配,因为最后2未匹配

You should fix the Angular validation to disallow partial string matches using您应该修复 Angular 验证以禁止使用部分字符串匹配

/^(?:(?:\+?011-?)?599(?:416|717|318)[0-9]{4}|08[58]-?[0-9]{7}(?:,[1-9][0-9]{1,8})?|(?:\+31|0|0031)[1-9][0-9]{2}-?[1-9][0-9]{5}(?:,[1-9][0-9]{1,8})?|(?:\+31|0|0031)[1-9][0-9]-?[1-9][0-9]{6}(?:,[1-9][0-9]{1,8})?|14-?0[1-9][0-9]{1,2}|(?:\+31|0|0031)6-?[1-9][0-9]{7}|\+(?:1\d{4,14}|2[078]\d{3,13}|3[0-469]\d{3,13}|4[013-9]\d{3,13}|5[1-9]\d{3,13}|6[0-6]\d{3,13}|7\d{4,14}|8[1-469]\d{3,13}|9[0-58]\d{3,13}|[2-9]\d{4,14}))$/

Note the regex literal notation, it should not be enclosed with any quotation marks.请注意正则表达式文字符号,不应使用任何引号括起来。

Actually, in JavaScript, you may use non-capturing groups ( (?:...) ) rather than capturing ones ( (...) ), to save some tiny bit of compuational resources.实际上,在 JavaScript 中,您可以使用非捕获组( (?:...) )而不是捕获组( (...) ),以节省一些计算资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM