/// <summary> /// Validate the property value. /// </summary> /// <param name="context">The <see cref="PropertyContext{TEntity, TProperty}"/>.</param> public override void Validate(PropertyContext <TEntity, TProperty> context) { var overrideVal = _func != null?_func(context.Parent.Value) : _value; // Compare the value against override to see if there is a difference. if (OnlyOverrideDefault && Comparer <TProperty> .Default.Compare(context.Value, default) != 0) { return; } context.OverrideValue(overrideVal); }
/// <summary> /// Validate the property value. /// </summary> /// <param name="context">The <see cref="PropertyContext{TEntity, TProperty}"/>.</param> public override async Task ValidateAsync(PropertyContext <TEntity, TProperty> context) { Beef.Check.NotNull(context, nameof(context)); // Compare the value against override to see if there is a difference. if (OnlyOverrideDefault && Comparer <TProperty> .Default.Compare(context.Value, default !) != 0) { return; } // Get the override value. var overrideVal = _func != null ? _func(context.Parent.Value) : (_funcAsync != null ? await _funcAsync(context.Parent.Value).ConfigureAwait(false) : _value); context.OverrideValue(overrideVal); }