You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a bit confused. Why NotEmpty() rule does not check if Guid argument is equal to default(Guid) and return that it's not valid?
Documentation says: Description: Ensures that the specified property is not null, an empty string or whitespace (or the default value for value types, eg 0 for int)
Since Guid is value type it should follow that rule. Am I missing something?
The text was updated successfully, but these errors were encountered:
pawepaw
changed the title
Why NotEmpty() does not check if Guid is default(Guid)?
Why NotEmpty() does not check if value for Guid type is default(Guid)?
Jul 26, 2017
NotEmpty does check if a Guid is equal to default(Guid). Is this not the behaviour you're seeing?
[Fact]
public void Guid_test() {
var validator = new TestModel2Validator();
var result = validator.Validate(new TestModel2 {
SomeId = default(Guid)
});
Assert.False(result.IsValid);
}
public class TestModel2Validator : AbstractValidator<TestModel2> {
public TestModel2Validator() {
RuleFor(x => x.SomeId).NotEmpty();
}
}
public class TestModel2 {
public Guid SomeId { get; set; }
}
Hello,
I'm a bit confused. Why NotEmpty() rule does not check if Guid argument is equal to default(Guid) and return that it's not valid?
Documentation says:
Description: Ensures that the specified property is not null, an empty string or whitespace (or the default value for value types, eg 0 for int)
Since Guid is value type it should follow that rule. Am I missing something?
The text was updated successfully, but these errors were encountered: