public final class ConditionalsValidator extends Object implements DependentPlugin
ConditionalAtRuleBlock
). This works in tandem with the Conditionals
plugin.
You can optionally specify a set of allowedConditions. If specified, each condition in the CSS will be checked against this set. If this check fails then an error will be reported.
Please note that each allowedCondition will be automatically lower-cased for comparison purposes! This aligns with the assumption of all other related conditionals plugins.
Also note that this will automatically enable the Conditionals
plugin, in passthroughMode (see ConditionalsConfig.passthroughMode(boolean)
) unless a Conditionals
plugin instance was registered before this one.
Constructor and Description |
---|
ConditionalsValidator()
Creates a new validator that will validate and refine the conditional at-rule blocks (syntax), but will not check
if the condition is allowed.
|
ConditionalsValidator(Iterable<String> allowedConditions)
Creates a new validator that will validate and refine the conditional at-rule blocks, and will also confirm that the
condition is within the given set of allowed conditions.
|
ConditionalsValidator(String... allowedConditions)
Creates a new validator that will validate and refine the conditional at-rule blocks (syntax), and will also confirm that
the condition is within the given set of allowed conditions.
|
Modifier and Type | Method and Description |
---|---|
void |
dependencies(PluginRegistry registry)
Registers plugin dependencies.
|
void |
validate(ConditionalAtRuleBlock block,
ErrorManager em)
Validation method.
|
public ConditionalsValidator()
public ConditionalsValidator(String... allowedConditions)
Please note that each allowedCondition will be automatically lower-cased for comparison purposes. This aligns with the assumption of all other related conditionals plugins.
allowedConditions
- The conditions that are allowed. Will be automatically lower-cased!public ConditionalsValidator(Iterable<String> allowedConditions)
Please note that each allowedCondition will be automatically lower-cased for comparison purposes. This aligns with the assumption of all other related conditionals plugins.
allowedConditions
- The conditions that are allowed. Will be automatically lower-cased!public void dependencies(PluginRegistry registry)
DependentPlugin
Any plugins you add to the registry in this method will be ordered before this plugin itself.
Keep in mind that only one instance of a plugin can be added in a single parsing operation. You can use PluginRegistry.require(Class)
, PluginRegistry.require(Class, Supplier)
and PluginRegistry.retrieve(Class)
to assist in scenarios where a plugin instance may have already been added.
Dependencies to include can range from refinement dependencies such as SelectorPlugin
and MediaPlugin
to
other custom plugins.
dependencies
in interface DependentPlugin
registry
- The PluginRegistry
instance.PluginRegistry.require(Class)
,
PluginRegistry.require(Class, Supplier)
,
PluginRegistry.retrieve(Class)
public void validate(ConditionalAtRuleBlock block, ErrorManager em)
block
- The block to validate.em
- The error manager.Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.