@@ -42,33 +42,34 @@ public class JsonMetaSchema {
42
42
static PatternFormat pattern (String name , String regex ) {
43
43
return new PatternFormat (name , regex );
44
44
}
45
- public static final List <Format > BUILTIN_FORMATS = new ArrayList <Format >();
45
+ public static final List <Format > COMMON_BUILTIN_FORMATS = new ArrayList <Format >();
46
46
47
47
// this section contains formats that is common for all specification versions.
48
48
static {
49
- BUILTIN_FORMATS .add (pattern ("time" , "^\\ d{2}:\\ d{2}:\\ d{2}$" ));
50
- BUILTIN_FORMATS .add (pattern ("ip-address" ,
49
+ COMMON_BUILTIN_FORMATS .add (pattern ("time" , "^\\ d{2}:\\ d{2}:\\ d{2}$" ));
50
+ COMMON_BUILTIN_FORMATS .add (pattern ("ip-address" ,
51
51
"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\ .){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" ));
52
- BUILTIN_FORMATS .add (pattern ("ipv4" ,
52
+ COMMON_BUILTIN_FORMATS .add (pattern ("ipv4" ,
53
53
"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\ .){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" ));
54
- BUILTIN_FORMATS .add (pattern ("ipv6" ,
54
+ COMMON_BUILTIN_FORMATS .add (pattern ("ipv6" ,
55
55
"^\\ s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)(\\ .(25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)(\\ .(25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)(\\ .(25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)(\\ .(25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)(\\ .(25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)(\\ .(25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)(\\ .(25[0-5]|2[0-4]\\ d|1\\ d\\ d|[1-9]?\\ d)){3}))|:)))(%.+)?\\ s*$" ));
56
- BUILTIN_FORMATS .add (pattern ("uri" , "(^[a-zA-Z][a-zA-Z0-9+-.]*:[^\\ s]*$)|(^//[^\\ s]*$)" ));
57
- BUILTIN_FORMATS .add (pattern ("color" ,
56
+ COMMON_BUILTIN_FORMATS .add (pattern ("uri" , "(^[a-zA-Z][a-zA-Z0-9+-.]*:[^\\ s]*$)|(^//[^\\ s]*$)" ));
57
+ COMMON_BUILTIN_FORMATS .add (pattern ("color" ,
58
58
"(#?([0-9A-Fa-f]{3,6})\\ b)|(aqua)|(black)|(blue)|(fuchsia)|(gray)|(green)|(lime)|(maroon)|(navy)|(olive)|(orange)|(purple)|(red)|(silver)|(teal)|(white)|(yellow)|(rgb\\ (\\ s*\\ b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\ b\\ s*,\\ s*\\ b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\ b\\ s*,\\ s*\\ b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\ b\\ s*\\ ))|(rgb\\ (\\ s*(\\ d?\\ d%|100%)+\\ s*,\\ s*(\\ d?\\ d%|100%)+\\ s*,\\ s*(\\ d?\\ d%|100%)+\\ s*\\ ))" ));
59
- BUILTIN_FORMATS .add (pattern ("hostname" ,
59
+ COMMON_BUILTIN_FORMATS .add (pattern ("hostname" ,
60
60
"^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\ -]{0,61}[a-zA-Z0-9])(\\ .([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\ -]{0,61}[a-zA-Z0-9]))*$" ));
61
- BUILTIN_FORMATS .add (pattern ("alpha" , "^[a-zA-Z]+$" ));
62
- BUILTIN_FORMATS .add (pattern ("alphanumeric" , "^[a-zA-Z0-9]+$" ));
63
- BUILTIN_FORMATS .add (pattern ("phone" , "^\\ +(?:[0-9] ?){6,14}[0-9]$" ));
64
- BUILTIN_FORMATS .add (pattern ("utc-millisec" , "^[0-9]+(\\ .?[0-9]+)?$" ));
65
- BUILTIN_FORMATS .add (pattern ("style" , "\\ s*(.+?):\\ s*([^;]+);?" ));
61
+ COMMON_BUILTIN_FORMATS .add (pattern ("alpha" , "^[a-zA-Z]+$" ));
62
+ COMMON_BUILTIN_FORMATS .add (pattern ("alphanumeric" , "^[a-zA-Z0-9]+$" ));
63
+ COMMON_BUILTIN_FORMATS .add (pattern ("phone" , "^\\ +(?:[0-9] ?){6,14}[0-9]$" ));
64
+ COMMON_BUILTIN_FORMATS .add (pattern ("utc-millisec" , "^[0-9]+(\\ .?[0-9]+)?$" ));
65
+ COMMON_BUILTIN_FORMATS .add (pattern ("style" , "\\ s*(.+?):\\ s*([^;]+);?" ));
66
66
}
67
67
68
68
private static class V4 {
69
69
private static String URI = "http://json-schema.org/draft-04/schema#" ;
70
70
private static final String ID = "id" ;
71
71
72
+ public static final List <Format > BUILTIN_FORMATS = new ArrayList <>(JsonMetaSchema .COMMON_BUILTIN_FORMATS );
72
73
static {
73
74
// add version specific formats here.
74
75
//BUILTIN_FORMATS.add(pattern("phone", "^\\+(?:[0-9] ?){6,14}[0-9]$"));
@@ -97,6 +98,7 @@ private static class V6 {
97
98
// Draft 6 uses "$id"
98
99
private static final String ID = "$id" ;
99
100
101
+ public static final List <Format > BUILTIN_FORMATS = new ArrayList <>(JsonMetaSchema .COMMON_BUILTIN_FORMATS );
100
102
static {
101
103
// add version specific formats here.
102
104
//BUILTIN_FORMATS.add(pattern("phone", "^\\+(?:[0-9] ?){6,14}[0-9]$"));
@@ -124,6 +126,7 @@ private static class V7 {
124
126
private static String URI = "http://json-schema.org/draft-07/schema#" ;
125
127
private static final String ID = "$id" ;
126
128
129
+ public static final List <Format > BUILTIN_FORMATS = new ArrayList <>(JsonMetaSchema .COMMON_BUILTIN_FORMATS );
127
130
static {
128
131
// add version specific formats here.
129
132
//BUILTIN_FORMATS.add(pattern("phone", "^\\+(?:[0-9] ?){6,14}[0-9]$"));
@@ -151,6 +154,7 @@ private static class V201909 {
151
154
private static String URI = "http://json-schema.org/draft/2019-09/schema#" ;
152
155
private static final String ID = "$id" ;
153
156
157
+ public static final List <Format > BUILTIN_FORMATS = new ArrayList <>(JsonMetaSchema .COMMON_BUILTIN_FORMATS );
154
158
static {
155
159
// add version specific formats here.
156
160
//BUILTIN_FORMATS.add(pattern("phone", "^\\+(?:[0-9] ?){6,14}[0-9]$"));
0 commit comments