question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for string based properties decorated with the RangeAttribute

See original GitHub issue

Consider the following:

public class MyModel
{
    [Required]
    [Range(1, 65535)]
    public string Port { get; set; }
}
var fixture = new Fixture();
var model = fixture.Create<MyModel>();

In 3.51.0 the first call the Create() worked, however subsequent calls threw, now in 4.0.0-rc1 (the version I am using), the first call throws ObjectCreationException whereas the attribute itself offers support for the use case.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jcasalecommented, Nov 8, 2017

To be honest, it’s a convention I am used to from the ASP arena and I don’t know if it’s an abuse of the facility or intended. I will check out the docs and if not, the reference source for logic that indicates it’s valid and expected and not simply a fragile coincidence.

0reactions
zvirjacommented, Dec 11, 2017

@jcasale Feel free to use the NumericRangedRequestRelay or EnumRangedRequestRelay as a sample of such customization.

This API will be available since our next release that should happen in the nearby future.

Closing this one as no further action is required so far. Feel free to ask more questions if you have 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Allow RangeAttribute to apply to properties in sub- ...
What I want to be able to do is decorate the Item and Item2 values on the MyViewModel with different range attributes. However...
Read more >
RangeAttribute Class (System.ComponentModel. ...
Initializes a new instance of the RangeAttribute class by using the specified minimum and maximum values and the specific type. Properties ...
Read more >
Range Attribute in ASP.NET MVC Application
In this article, I am going to discuss Range Attribute in ASP. ... and 25 as the maximum length then we can decorate...
Read more >
(C#) Is it possible to define range attributes with instance ...
Hey all, I was wondering if it would be possible for me to accomplish limiting a field's range in the editor to below...
Read more >
Range Attribute, Custom Attribute & Custom Validation
This attribute can set a range of valid value for each property with different property type. Also, Range attribute is in System.ComponentModel.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found