Table of Contents

Class ScalarValueModelBinderBase<TResult, TValue, TPrimitive>

Namespace
Trellis.Asp.ModelBinding
Assembly
Trellis.Asp.dll

Base model binder for scalar value types that handles primitive conversion, validation via TryCreate, and error collection.

public abstract class ScalarValueModelBinderBase<TResult, TValue, TPrimitive> : IModelBinder where TValue : IScalarValue<TValue, TPrimitive> where TPrimitive : IComparable

Type Parameters

TResult

The result type of binding (e.g., TValue or Maybe<TValue>).

TValue

The scalar value object type.

TPrimitive

The underlying primitive type.

Inheritance
ScalarValueModelBinderBase<TResult, TValue, TPrimitive>
Implements
Derived
Inherited Members
Extension Methods

Methods

BindModelAsync(ModelBindingContext)

Attempts to bind a model.

public Task BindModelAsync(ModelBindingContext bindingContext)

Parameters

bindingContext ModelBindingContext

The ModelBindingContext.

Returns

Task

A Task which will complete when the model binding process completes.

If model binding was successful, the Result should have IsModelSet set to true.

A model binder that completes successfully should set Result to a value returned from Success(object).

OnEmptyValue()

Returns the binding result when an empty string is provided. Returns null to continue with normal conversion logic.

protected virtual ModelBindingResult? OnEmptyValue()

Returns

ModelBindingResult?

OnMissingValue()

Returns the binding result when no value is provided.

protected abstract ModelBindingResult OnMissingValue()

Returns

ModelBindingResult

OnSuccess(TValue)

Wraps a successfully validated value object into the binding result.

protected abstract ModelBindingResult OnSuccess(TValue value)

Parameters

value TValue

Returns

ModelBindingResult