Class Validator
- Namespace
- arolariu.Backend.Common.Validators
- Assembly
- arolariu.Backend.Common.dll
Validator that checks if an object meets a certain criteria.
public static class Validator
- Inheritance
-
Validator
- Inherited Members
Methods
ValidateAndThrow<TObject, TException>(TObject?, Func<TObject?, bool>, string)
Validates and throws an exception if the object does not meet the criteria.
public static void ValidateAndThrow<TObject, TException>(TObject? @object, Func<TObject?, bool> predicate, string message) where TException : Exception, new()
Parameters
Type Parameters
TObject
TException
ValidateObjectAndThrow<TObject, TException>(TObject?, Func<TObject?, bool>, string)
Validates a class object.
private static void ValidateObjectAndThrow<TObject, TException>(TObject? @object, Func<TObject?, bool> predicate, string message) where TException : Exception, new()
Parameters
Type Parameters
TObject
TException
Examples
Validator.ValidateClassObject(object, object => object is not null);