BasketProductLineFieldValidationContext Class
The BasketProductLineFieldValidationContext record provides contextual information for validating basket product line. It encapsulates the field value, basket line context, user information, and account information that might be needed during validation.

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.
LineContext
public BasketProductLineFieldLineContext LineContext { get; }
The basket line context. Contains quantity, unit of measure, product, and variant information for the line being validated.
See BasketProductLineFieldLineContext below for detailed information.
User
public WebstoreUserInfo User { get; }
The current user browsing the web store. This can be used to implement user-specific validation rules.
See WebstoreUserInfo reference for detailed information.
Account
public AccountInfo Account { get; }
The current ERP account which is used to communicate with ERP. This can be used for account-specific validation rules.
See AccountInfo reference for detailed information.
BasketProductLineFieldLineContext Record
A context used to validate basket product line field. Backward compatibility of this constructor is not guaranteed.
The BasketProductLineFieldLineContext record provides basket line information for product line field validation.
Properties
Quantity
public decimal Quantity { get; }
The basket line quantity.
UnitOfMeasureId
public string? UnitOfMeasureId { get; }
The basket line unit of measure identifier.
Product
public BasketProductLineFieldLineContext.ProductInfo Product { get; }
The basket line product.
See ProductInfo below for detailed information.
Variant
public BasketProductLineFieldLineContext.VariantInfo? Variant { get; }
The basket line variant. Can be null when the line has no variant.
See VariantInfo below for detailed information.
ProductInfo Record
Product information. Backward compatibility of this constructor is not guaranteed.
Id
public string Id { get; }
The product identifier.
Attributes
public IEnumerable<ProductAddonField> Attributes { get; }
The product attributes.
See ProductAddonField reference for detailed information.
VariantInfo Record
Variant information. Backward compatibility of this constructor is not guaranteed.
Id
public string Id { get; }
The variant identifier.
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();
var quantity = context.LineContext.Quantity;
var productId = context.LineContext.Product.Id;
if (string.IsNullOrWhiteSpace(value)
|| value.Length < 3)
{
return ValueTask.FromResult(false);
}
if (quantity > 100 && context.Account.Type == AccountType.Customer)
{
return ValueTask.FromResult(false);
}
return ValueTask.FromResult(true);
}