Sana Assistant (online)
Table of Contents

BasketProductLineFieldValidationContext Class

The BasketProductLineFieldValidationContext class provides contextual information for validating basket product line field values. It encapsulates the field value that needs to be validated.

BasketProductLineFieldValidationContext class diagram

Properties

Value

public ErpFieldValue? Value { get; }

The product line field value to validate. This is the value entered by the user or provided by the system that needs to be validated according to your custom validation rules.

The value can be null if no value has been provided for the field.

Example Usage

Here's an example of using the BasketProductLineFieldValidationContext in a validation method:

public override ValueTask<bool> ValidateFieldValueAsync(
    BasketProductLineFieldValidationContext context, 
    CancellationToken cancellationToken)
{
    var value = context.Value?.AsString()?.Trim();

    if (string.IsNullOrWhiteSpace(value)
        || value.Length < 3)
    {
        return ValueTask.FromResult(false);
    }

    return ValueTask.FromResult(true);
}

See Also