mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-13 05:48:40 +00:00
Improved Parameter validation
This commit is contained in:
parent
55a8d3f261
commit
4afbcdbca8
@ -9,6 +9,8 @@ public static class ParameterExtension
|
|||||||
public static void Validate(this StableDiffusionParameter parameter)
|
public static void Validate(this StableDiffusionParameter parameter)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(parameter, nameof(parameter));
|
ArgumentNullException.ThrowIfNull(parameter, nameof(parameter));
|
||||||
|
ArgumentNullException.ThrowIfNull(parameter.ControlNet, nameof(StableDiffusionParameter.ControlNet));
|
||||||
|
ArgumentNullException.ThrowIfNull(parameter.PhotoMaker, nameof(StableDiffusionParameter.PhotoMaker));
|
||||||
ArgumentNullException.ThrowIfNull(parameter.NegativePrompt, nameof(StableDiffusionParameter.NegativePrompt));
|
ArgumentNullException.ThrowIfNull(parameter.NegativePrompt, nameof(StableDiffusionParameter.NegativePrompt));
|
||||||
|
|
||||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(parameter.Width, nameof(StableDiffusionParameter.Width));
|
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(parameter.Width, nameof(StableDiffusionParameter.Width));
|
||||||
@ -20,10 +22,8 @@ public static class ParameterExtension
|
|||||||
|
|
||||||
if (!Enum.IsDefined(parameter.SampleMethod)) throw new ArgumentOutOfRangeException(nameof(StableDiffusionParameter.SampleMethod));
|
if (!Enum.IsDefined(parameter.SampleMethod)) throw new ArgumentOutOfRangeException(nameof(StableDiffusionParameter.SampleMethod));
|
||||||
|
|
||||||
// ReSharper disable ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
|
parameter.ControlNet.Validate();
|
||||||
parameter.ControlNet?.Validate();
|
parameter.PhotoMaker.Validate();
|
||||||
parameter.PhotoMaker?.Validate();
|
|
||||||
// ReSharper restore ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Validate(this StableDiffusionControlNetParameter parameter)
|
public static void Validate(this StableDiffusionControlNetParameter parameter)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user