Add fail on invalid property for maps.
This commit is contained in:
@@ -18,10 +18,14 @@ pub struct LanguageOptions {
|
||||
pub allow_anonymous_fn: bool,
|
||||
/// Is looping allowed?
|
||||
pub allow_looping: bool,
|
||||
/// Strict variables mode?
|
||||
pub strict_var: bool,
|
||||
/// Is variables shadowing allowed?
|
||||
pub allow_shadowing: bool,
|
||||
/// Strict variables mode?
|
||||
pub strict_var: bool,
|
||||
/// Raise error if an object map property does not exist?
|
||||
/// Returns `()` if `false`.
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
pub fail_on_invalid_map_property: bool,
|
||||
}
|
||||
|
||||
impl LanguageOptions {
|
||||
@@ -37,6 +41,8 @@ impl LanguageOptions {
|
||||
allow_looping: true,
|
||||
strict_var: false,
|
||||
allow_shadowing: true,
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
fail_on_invalid_map_property: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,6 +55,7 @@ impl Default for LanguageOptions {
|
||||
|
||||
impl Engine {
|
||||
/// Is `if`-expression allowed?
|
||||
/// Default is `true`.
|
||||
#[inline(always)]
|
||||
pub fn allow_if_expression(&self) -> bool {
|
||||
self.options.allow_if_expr
|
||||
@@ -59,6 +66,7 @@ impl Engine {
|
||||
self.options.allow_if_expr = enable;
|
||||
}
|
||||
/// Is `switch` expression allowed?
|
||||
/// Default is `true`.
|
||||
#[inline(always)]
|
||||
pub fn allow_switch_expression(&self) -> bool {
|
||||
self.options.allow_switch_expr
|
||||
@@ -69,6 +77,7 @@ impl Engine {
|
||||
self.options.allow_switch_expr = enable;
|
||||
}
|
||||
/// Is statement-expression allowed?
|
||||
/// Default is `true`.
|
||||
#[inline(always)]
|
||||
pub fn allow_statement_expression(&self) -> bool {
|
||||
self.options.allow_stmt_expr
|
||||
@@ -79,6 +88,7 @@ impl Engine {
|
||||
self.options.allow_stmt_expr = enable;
|
||||
}
|
||||
/// Is anonymous function allowed?
|
||||
/// Default is `true`.
|
||||
///
|
||||
/// Not available under `no_function`.
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
@@ -95,6 +105,7 @@ impl Engine {
|
||||
self.options.allow_anonymous_fn = enable;
|
||||
}
|
||||
/// Is looping allowed?
|
||||
/// Default is `true`.
|
||||
#[inline(always)]
|
||||
pub fn allow_looping(&self) -> bool {
|
||||
self.options.allow_looping
|
||||
@@ -104,17 +115,8 @@ impl Engine {
|
||||
pub fn set_allow_looping(&mut self, enable: bool) {
|
||||
self.options.allow_looping = enable;
|
||||
}
|
||||
/// Is strict variables mode enabled?
|
||||
#[inline(always)]
|
||||
pub fn strict_variables(&self) -> bool {
|
||||
self.options.strict_var
|
||||
}
|
||||
/// Set whether strict variables mode is enabled.
|
||||
#[inline(always)]
|
||||
pub fn set_strict_variables(&mut self, enable: bool) {
|
||||
self.options.strict_var = enable;
|
||||
}
|
||||
/// Is variables shadowing allowed?
|
||||
/// Default is `true`.
|
||||
#[inline(always)]
|
||||
pub fn allow_shadowing(&self) -> bool {
|
||||
self.options.allow_shadowing
|
||||
@@ -124,4 +126,32 @@ impl Engine {
|
||||
pub fn set_allow_shadowing(&mut self, enable: bool) {
|
||||
self.options.allow_shadowing = enable;
|
||||
}
|
||||
/// Is strict variables mode enabled?
|
||||
/// Default is `false`.
|
||||
#[inline(always)]
|
||||
pub fn strict_variables(&self) -> bool {
|
||||
self.options.strict_var
|
||||
}
|
||||
/// Set whether strict variables mode is enabled.
|
||||
#[inline(always)]
|
||||
pub fn set_strict_variables(&mut self, enable: bool) {
|
||||
self.options.strict_var = enable;
|
||||
}
|
||||
/// Raise error if an object map property does not exist?
|
||||
/// Default is `false`.
|
||||
///
|
||||
/// Not available under `no_object`.
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
#[inline(always)]
|
||||
pub fn fail_on_invalid_map_property(&self) -> bool {
|
||||
self.options.fail_on_invalid_map_property
|
||||
}
|
||||
/// Set whether to raise error if an object map property does not exist.
|
||||
///
|
||||
/// Not available under `no_object`.
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
#[inline(always)]
|
||||
pub fn set_fail_on_invalid_map_property(&mut self, enable: bool) {
|
||||
self.options.fail_on_invalid_map_property = enable;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user