Class PredicateValidator<T>
- Namespace
- SteamNetworkLib.Sync
- Assembly
- SteamNetworkLib.dll
Base class for simple validators using a predicate function.
public class PredicateValidator<T> : ISyncValidator<T>
Type Parameters
TThe type of value to validate.
- Inheritance
-
PredicateValidator<T>
- Implements
- Inherited Members
Constructors
PredicateValidator(Func<T, bool>, string)
Creates a new predicate-based validator.
public PredicateValidator(Func<T, bool> predicate, string errorMessage)
Parameters
predicateFunc<T, bool>Function that returns true if the value is valid.
errorMessagestringError message to return when validation fails.
Methods
GetErrorMessage(T)
Gets a human-readable error message describing why validation failed.
public string? GetErrorMessage(T value)
Parameters
valueTThe invalid value.
Returns
- string
An error message, or null if no specific message is available.
IsValid(T)
Validates a value before it is synchronized.
public bool IsValid(T value)
Parameters
valueTThe value to validate.
Returns
- bool
True if the value is valid, false otherwise.