MiniValidation icon indicating copy to clipboard operation
MiniValidation copied to clipboard

Support required modifier

Open Corniel opened this issue 9 months ago • 0 comments

It would be nice if the required modifier could be considered a way of making properties required. You could thing of the following:

class Model
{
    public required string MakeRequired { get; init; } // When analyzing this property, add a default instance of a RequiredAttribute to the list of validation attributes/

    public required int ValueType { get; init; } // Ignore, adding a required attribute will not change a thing.
  
    public required string? NullableReference { get; init; } // Ingore, it must be set, but null is considered valid option.

    [Any]
    public required int[] SomeObject { get; init; } // Ignore, AnyAttribute inherits from RequiredAttribute and should prevail.
}

What do you think?

Corniel avatar Mar 21 '25 09:03 Corniel