ImmediatePlatform / Immediate.Validations

Source generated validations for Immediate.Handlers parameters
MIT License
4 stars 2 forks source link

Relax `[TargetType]` Constraints or Provide Strict Mode Toggle #57

Open tcortega opened 2 months ago

tcortega commented 2 months ago

It's unfortunate that I'm forced to disable warnings using pragma when utilizing the GreaterThanAttribute with properties of type decimal or similar. For example:

[GreaterThan(0)]
public required decimal Amount { get; set; }

This results in the following warning:

Warning IV0015: Property/parameter `operand` is marked `[TargetType]`, but value is not of type `decimal`

Having a way to relax the constraints of [TargetType] or an option to toggle a strict mode would significantly improve this experience. Because this becomes unbearable if your project is treating warnings as errors.

viceroypenguin commented 2 months ago

This is easily addressed by using [GreaterThan(0m)]. Further consideration is not warranted as integers are the only values where this type of mismatch is possible, and suffixes, which are common, are easily added.

tcortega commented 2 months ago

Decimals can't be constants. That's where the issue arises.