Table of Contents

Class ScalarValueModelBinder<TValue, TPrimitive>

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

Model binder for scalar value types. Validates scalar values during model binding by calling TryCreate.

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

Type Parameters

TValue

The scalar value type.

TPrimitive

The underlying primitive type.

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

Remarks

This binder is automatically used for any type that implements IScalarValue<TSelf, TPrimitive>. It intercepts model binding and calls the static TryCreate method to create validated scalar values.

Validation errors are added to ModelStateDictionary, which integrates with ASP.NET Core's standard validation infrastructure. When used with [ApiController], invalid requests automatically return 400 Bad Request.

Methods

OnMissingValue()

Returns the binding result when no value is provided.

protected override ModelBindingResult OnMissingValue()

Returns

ModelBindingResult

OnSuccess(TValue)

Wraps a successfully validated value object into the binding result.

protected override ModelBindingResult OnSuccess(TValue value)

Parameters

value TValue

Returns

ModelBindingResult