@@ -11,11 +11,8 @@ use crate::isl::util::{
11
11
Annotation , Ieee754InterchangeFormat , TimestampOffset , TimestampPrecision , ValidValue ,
12
12
} ;
13
13
use crate :: isl:: IslVersion ;
14
- use crate :: isl_require;
15
14
use crate :: ordered_elements_nfa:: OrderedElementsNfa ;
16
- use crate :: result:: {
17
- invalid_schema_error, invalid_schema_error_raw, IonSchemaResult , ValidationResult ,
18
- } ;
15
+ use crate :: result:: { invalid_schema, isl_require, IonSchemaResult , ValidationResult } ;
19
16
use crate :: system:: { PendingTypes , TypeId , TypeStore } ;
20
17
use crate :: type_reference:: { TypeReference , VariablyOccurringTypeRef } ;
21
18
use crate :: types:: TypeValidator ;
@@ -1916,9 +1913,7 @@ impl RegexConstraint {
1916
1913
. case_insensitive ( isl_regex. case_insensitive ( ) )
1917
1914
. multi_line ( isl_regex. multi_line ( ) )
1918
1915
. build ( )
1919
- . map_err ( |e| {
1920
- invalid_schema_error_raw ( format ! ( "Invalid regex {}" , isl_regex. expression( ) ) )
1921
- } ) ?;
1916
+ . map_err ( |e| invalid_schema ! ( "Invalid regex {}" , isl_regex. expression( ) ) ) ?;
1922
1917
1923
1918
Ok ( RegexConstraint :: new (
1924
1919
regex,
@@ -1948,7 +1943,7 @@ impl RegexConstraint {
1948
1943
sb. push ( ch) ;
1949
1944
if let Some ( ch) = si. next ( ) {
1950
1945
if ch == '?' {
1951
- return invalid_schema_error ( format ! ( "invalid character {ch}" ) ) ;
1946
+ return invalid_schema ! ( "invalid character {ch}" ) ;
1952
1947
}
1953
1948
sb. push ( ch)
1954
1949
}
@@ -1965,11 +1960,7 @@ impl RegexConstraint {
1965
1960
}
1966
1961
's' => sb. push_str ( "[ \\ f\\ n\\ r\\ t]" ) ,
1967
1962
'S' => sb. push_str ( "[^ \\ f\\ n\\ r\\ t]" ) ,
1968
- _ => {
1969
- return invalid_schema_error ( format ! (
1970
- "invalid escape character {ch}" ,
1971
- ) )
1972
- }
1963
+ _ => return invalid_schema ! ( "invalid escape character {ch}" , ) ,
1973
1964
}
1974
1965
}
1975
1966
}
@@ -1993,10 +1984,10 @@ impl RegexConstraint {
1993
1984
match ch {
1994
1985
'&' => {
1995
1986
if si. peek ( ) == Some ( & '&' ) {
1996
- return invalid_schema_error ( "'&&' is not supported in a character class" ) ;
1987
+ return invalid_schema ! ( "'&&' is not supported in a character class" ) ;
1997
1988
}
1998
1989
}
1999
- '[' => return invalid_schema_error ( "'[' must be escaped within a character class" ) ,
1990
+ '[' => return invalid_schema ! ( "'[' must be escaped within a character class" ) ,
2000
1991
'\\' => {
2001
1992
if let Some ( ch2) = si. next ( ) {
2002
1993
match ch2 {
@@ -2006,10 +1997,10 @@ impl RegexConstraint {
2006
1997
match isl_version {
2007
1998
IslVersion :: V1_0 => {
2008
1999
// returns an error for ISL 1.0 as it does not support pre-defined char classes (i.e., \d, \s, \w)
2009
- return invalid_schema_error ( format ! (
2000
+ return invalid_schema ! (
2010
2001
"invalid sequence '{:?}' in character class" ,
2011
2002
si
2012
- ) ) ;
2003
+ ) ;
2013
2004
}
2014
2005
IslVersion :: V2_0 => {
2015
2006
// Change \w and \W to be [a-zA-Z0-9_] and [^a-zA-Z0-9_] respectively
@@ -2028,9 +2019,9 @@ impl RegexConstraint {
2028
2019
}
2029
2020
}
2030
2021
_ => {
2031
- return invalid_schema_error ( format ! (
2022
+ return invalid_schema ! (
2032
2023
"invalid sequence '\\ {ch2}' in character class"
2033
- ) )
2024
+ )
2034
2025
}
2035
2026
}
2036
2027
}
@@ -2040,7 +2031,7 @@ impl RegexConstraint {
2040
2031
}
2041
2032
}
2042
2033
2043
- invalid_schema_error ( "character class missing ']'" )
2034
+ invalid_schema ! ( "character class missing ']'" )
2044
2035
}
2045
2036
2046
2037
fn parse_quantifier ( sb : & mut String , si : & mut Peekable < Chars < ' _ > > ) -> IonSchemaResult < ( ) > {
@@ -2069,22 +2060,22 @@ impl RegexConstraint {
2069
2060
complete = true ;
2070
2061
break ;
2071
2062
}
2072
- _ => return invalid_schema_error ( format ! ( "invalid character {ch}" ) ) ,
2063
+ _ => return invalid_schema ! ( "invalid character {ch}" ) ,
2073
2064
}
2074
2065
}
2075
2066
2076
2067
if !complete {
2077
- return invalid_schema_error ( "range quantifier missing '}'" ) ;
2068
+ return invalid_schema ! ( "range quantifier missing '} }'" ) ;
2078
2069
}
2079
2070
}
2080
2071
_ => { }
2081
2072
}
2082
2073
if sb. len ( ) > initial_length {
2083
2074
if let Some ( ch) = si. peek ( ) . cloned ( ) {
2084
2075
match ch {
2085
- '?' => return invalid_schema_error ( format ! ( "invalid character {ch}" ) ) ,
2076
+ '?' => return invalid_schema ! ( "invalid character {ch}" ) ,
2086
2077
2087
- '+' => return invalid_schema_error ( format ! ( "invalid character {ch}" ) ) ,
2078
+ '+' => return invalid_schema ! ( "invalid character {ch}" ) ,
2088
2079
_ => { }
2089
2080
}
2090
2081
}
0 commit comments