pub struct JavaScriptValidator { /* private fields */ }Expand description
JavaScript constraint validator
Executes JavaScript code for constraint validation using a sandboxed runtime.
The JavaScript code should define a function validate(value, parameters) that
returns a boolean or an object with valid: boolean and optional message: string.
Implementations§
Source§impl JavaScriptValidator
impl JavaScriptValidator
Sourcepub fn new(
component_id: ConstraintComponentId,
metadata: ComponentMetadata,
code: String,
) -> Self
pub fn new( component_id: ConstraintComponentId, metadata: ComponentMetadata, code: String, ) -> Self
Create a new JavaScript validator
Sourcepub fn with_config(self, config: RuntimeConfig) -> Self
pub fn with_config(self, config: RuntimeConfig) -> Self
Create with custom configuration
Sourcepub fn with_security_policy(self, policy: SecurityPolicy) -> Self
pub fn with_security_policy(self, policy: SecurityPolicy) -> Self
Create with custom security policy
Sourcepub fn execute(
&self,
_value: &Term,
_parameters: &HashMap<String, Term>,
) -> Result<ComponentExecutionResult>
pub fn execute( &self, _value: &Term, _parameters: &HashMap<String, Term>, ) -> Result<ComponentExecutionResult>
Execute JavaScript validation.
No sandboxed JavaScript runtime is wired into this build, so a configured
JavaScript validator MUST NOT silently report conformance (which would
pass every focus node regardless of the actual validation logic).
Instead this fails loud with ShaclError::UnsupportedOperation, in line
with the project’s fail-loud contract. Wiring a real sandboxed engine
(e.g. QuickJS via rquickjs, or Boa) would replace this method body.
Sourcepub fn validate_code(&self) -> Result<()>
pub fn validate_code(&self) -> Result<()>
Validate the JavaScript code syntax
Trait Implementations§
Source§impl Clone for JavaScriptValidator
impl Clone for JavaScriptValidator
Source§impl CustomConstraintComponent for JavaScriptValidator
impl CustomConstraintComponent for JavaScriptValidator
Source§fn component_id(&self) -> &ConstraintComponentId
fn component_id(&self) -> &ConstraintComponentId
Source§fn metadata(&self) -> &ComponentMetadata
fn metadata(&self) -> &ComponentMetadata
Source§fn validate_configuration(
&self,
_parameters: &HashMap<String, Term>,
) -> Result<()>
fn validate_configuration( &self, _parameters: &HashMap<String, Term>, ) -> Result<()>
Source§fn create_constraint(
&self,
parameters: HashMap<String, Term>,
) -> Result<CustomConstraint>
fn create_constraint( &self, parameters: HashMap<String, Term>, ) -> Result<CustomConstraint>
Source§fn sparql_template(&self) -> Option<&str>
fn sparql_template(&self) -> Option<&str>
Source§fn sparql_prefixes(&self) -> Option<&str>
fn sparql_prefixes(&self) -> Option<&str>
Auto Trait Implementations§
impl Freeze for JavaScriptValidator
impl RefUnwindSafe for JavaScriptValidator
impl Send for JavaScriptValidator
impl Sync for JavaScriptValidator
impl Unpin for JavaScriptValidator
impl UnsafeUnpin for JavaScriptValidator
impl UnwindSafe for JavaScriptValidator
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.