London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Class ParameterValidator

Contains strongly typed validation methods

Inheritance
System.Object
ParameterValidator
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Commerce.Validation
Assembly: EPiServer.Business.Commerce.dll
Version: 13.30.0
Syntax
[Obsolete("Use the correspoinding validation methods on EPiServer.Framework.Validator and use the nameof operator to get the parameter name. Will remain at least until May 2019.")]
public class ParameterValidator

Constructors

ParameterValidator()

Declaration
public ParameterValidator()

Methods

ThrowIfNull<T>(Expression<Func<T>>, T)

Throws an System.ArgumentNullException based on if is null.

Declaration
public static void ThrowIfNull<T>(Expression<Func<T>> expression, T value)
Parameters
Type Name Description
System.Linq.Expressions.Expression<System.Func<T>> expression

An expression containing the property to validate

T value

the property again

Type Parameters
Name Description
T

The type in the expression

Examples

If your property has a parameter named "foo" you can use this:

ParameterValidator.ThrowIfNull(() => foo, foo);

ThrowIfNullOrEmpty(Expression<Func<String>>, String)

Throws an System.ArgumentNullException based on if is null or empty.

Declaration
public static void ThrowIfNullOrEmpty(Expression<Func<string>> expression, string value)
Parameters
Type Name Description
System.Linq.Expressions.Expression<System.Func<System.String>> expression

An expression containing the property to validate

System.String value

the property again

Examples

If your property has a string parameter named "foo" you can use this:

ParameterValidator.ThrowIfNullOrEmpty(() => foo, foo);