private static Func<IEnumerable<SpecificationProperty>, IEnumerable<Maybe<Error>>> EnforceRange()
{
return specProps =>
{
var options = specProps.Where(
sp => sp.Specification.ConversionType.ToDescriptor() == DescriptorType.Sequence
&& sp.Value.IsJust()
&& ((Array)sp.Value.FromJust()).Length < sp.Specification.Min);
if (options.Any())
{
return options.Select(s => Maybe.Just<Error>(new SequenceOutOfRangeError(
NameInfo.FromSpecification(s.Specification))));
}
return Enumerable.Empty<Nothing<Error>>();
};
}
}