Class ConfigKeyValidator<T>
- Namespace
- MonkeyLoader.Configuration
- Assembly
- MonkeyLoader.dll
Implements a validator component for IDefiningConfigKey<T>s using Predicate<T>s.
Multiple IConfigKeyValidator<T> instances on one config key must all validate successfully.
public sealed class ConfigKeyValidator<T> : IConfigKeyValidator<T>, IConfigKeyComponent<IDefiningConfigKey<T>>, IComponent<IDefiningConfigKey<T>>
Type Parameters
T
The type of the config item's value.
- Inheritance
-
ConfigKeyValidator<T>
- Implements
- Inherited Members
Constructors
ConfigKeyValidator(Predicate<T?>)
Creates a new validator component using a predicate for validation.
public ConfigKeyValidator(Predicate<T?> validator)
Parameters
validator
Predicate<T>The value validator.
Properties
NotNull
Gets a validator component that only accepts non-null values.
public static IConfigKeyValidator<T> NotNull { get; }
Property Value
Methods
Initialize(IDefiningConfigKey<T>)
Initializes this component when it's added to an
entity's component list.
This may throw a InvalidOperationException when the state of the given entity is invalid for this component.
public void Initialize(IDefiningConfigKey<T> configKey)
Parameters
configKey
IDefiningConfigKey<T>
Exceptions
- InvalidOperationException
When the state of the given entity is invalid.
IsValid(T?)
Whether value
is valid for this IDefiningConfigKey<T>.
public bool IsValid(T? value)
Parameters
value
TThe value to check.
Returns
- bool
true
if thevalue
is valid; otherwise,false
.