Rules added for optional string fields, but if it's not null or empty, some specific length is required (minimum, maximum or exact).
var someStr = "test";var wrong = new Contract().HasMinLengthIfNotNullOrEmpty(someStr, 10, "string property", "10 characters is the minimum length if string is not null or empty");var right = new Contract().HasMinLengthIfNotNullOrEmpty(someStr, 3, "string property", "3 characters is the minimum length if string is not null or empty");var rightAgain = new Contract().HasMinLengthIfNotNullOrEmpty(null, 3, "string property", "3 characters is the minimum length if string is not null or empty");
Rules added for optional string fields, but if it's not null or empty, some specific length is required (minimum, maximum or exact).
var someStr = "test";
var wrong = new Contract().HasMinLengthIfNotNullOrEmpty(someStr, 10, "string property", "10 characters is the minimum length if string is not null or empty");
var right = new Contract().HasMinLengthIfNotNullOrEmpty(someStr, 3, "string property", "3 characters is the minimum length if string is not null or empty");
var rightAgain = new Contract().HasMinLengthIfNotNullOrEmpty(null, 3, "string property", "3 characters is the minimum length if string is not null or empty");