generated from Avanade/avanade-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathValidationArgs.cs
71 lines (60 loc) · 3.29 KB
/
ValidationArgs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/CoreEx
using CoreEx.Configuration;
using CoreEx.Entities;
using System.Collections.Generic;
namespace CoreEx.Validation
{
/// <summary>
/// Represents the optional extended arguments for an entity validation.
/// </summary>
public class ValidationArgs
{
private static bool? _defaultUseJsonNames;
/// <summary>
/// Initializes a new instance of the <see cref="ValidationArgs"/> class.
/// </summary>
public ValidationArgs() { }
/// <summary>
/// Indicates whether to use the JSON name for the <see cref="MessageItem"/> <see cref="MessageItem.Property"/>; by default (<c>false</c>) uses the .NET name.
/// </summary>
/// <remarks>Will attempt to use <see cref="SettingsBase.ValidationUseJsonNames"/> as a default where possible.</remarks>
public static bool DefaultUseJsonNames
{
get => _defaultUseJsonNames ?? ExecutionContext.GetService<SettingsBase>()?.ValidationUseJsonNames ?? false;
set => _defaultUseJsonNames = value;
}
/// <summary>
/// Gets or sets the optional name of a selected (specific) property to validate for the entity (<c>null</c> indicates to validate all).
/// </summary>
/// <remarks>Nested or fully quailified entity names are not supported for this type of validation; only a property of the primary entity can be selected.</remarks>
public string? SelectedPropertyName { get; set; }
/// <summary>
/// Gets or sets the entity prefix used for fully qualified <i>entity.property</i> naming (<c>null</c> represents the root).
/// </summary>
public string? FullyQualifiedEntityName { get; set; }
/// <summary>
/// Gets or sets the entity prefix used for fully qualified <i>entity.property</i> naming (<c>null</c> represents the root).
/// </summary>
public string? FullyQualifiedJsonEntityName { get; set; }
/// <summary>
/// Indicates (overrides <see cref="DefaultUseJsonNames"/>) whether to use the JSON name for the <see cref="MessageItem"/> <see cref="MessageItem.Property"/>;
/// defaults to <c>null</c> (uses the <see cref="DefaultUseJsonNames"/> value).
/// </summary>
public bool? UseJsonNames { get; set; }
/// <summary>
/// Gets <see cref="UseJsonNames"/> selection.
/// </summary>
internal bool UseJsonNamesSelection => UseJsonNames ?? DefaultUseJsonNames;
/// <summary>
/// Indicates that a shallow validation is required; i.e. will only validate the top level properties.
/// </summary>
/// <remarks>The default deep validation will not only validate the top level properties, but also those children down the object graph;
/// i.e. sub-objects and collections.</remarks>
public bool ShallowValidation { get; set; }
/// <summary>
/// Gets the configuration parameters.
/// </summary>
/// <remarks>Configuration parameters provide a means to pass values down through the validation stack. The consuming developer must instantiate the property on first use.</remarks>
public IDictionary<string, object?>? Config { get; set; }
}
}