DataAnnotationsBehavior Class

Definition

Rejects a call whose arguments fail the data annotations registered for that member.

public sealed class DataAnnotationsBehavior : IStuntBehavior

Remarks

Devlooped.DataAnnotations.NativeValidator and its source generator own the checks. This behavior looks the registration up before the rest of the pipeline. A property is checked on its setter. A method or constructor is checked through its annotated parameters. Getters are left alone. The first failure is a , and the rest of the pipeline does not run.

Add this behavior after the behaviors that should observe the rejection, and ahead of the behaviors that should see only valid calls. The pipeline runs the first behavior outermost, so adding this one last places the check immediately before the target.

reads the other property from the instance. On a stunt that call re-enters the pipeline. A SynchronizedBehavior wrapped outside this one throws on that re-entry, because the thread already holds the lock.

StuntGeneratorAttribute derives from ValidationAttribute, so the generator treats a generic [StuntGenerator] method as a validated factory and registers the closed types that call names. A factory that is not a stunt generator uses Devlooped.DataAnnotations.ValidatedAttribute. A closed type with no factory call uses [assembly: Validate<T>].

Tip: use kind:method, kind:property, kind:ctor. Press Esc to clear.

Methods (2)