generated from Avanade/avanade-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathIPropertyContext.cs
82 lines (69 loc) · 3.18 KB
/
IPropertyContext.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
72
73
74
75
76
77
78
79
80
81
82
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/CoreEx
using CoreEx.Entities;
using CoreEx.Localization;
namespace CoreEx.Validation
{
/// <summary>
/// Enables a validation context for a property.
/// </summary>
public interface IPropertyContext
{
/// <summary>
/// Gets the <see cref="IValidationContext"/> for the parent entity.
/// </summary>
IValidationContext Parent { get; }
/// <summary>
/// Gets the property name.
/// </summary>
string Name { get; }
/// <summary>
/// Gets the JSON property name.
/// </summary>
string JsonName { get; }
/// <summary>
/// Gets the property text.
/// </summary>
string Text { get; }
/// <summary>
/// Gets the property value.
/// </summary>
object? Value { get; }
/// <summary>
/// Gets the fully qualified property name.
/// </summary>
string FullyQualifiedPropertyName { get; }
/// <summary>
/// Gets the fully qualified Json property name.
/// </summary>
string FullyQualifiedJsonPropertyName { get; }
/// <summary>
/// Indicates whether there has been a validation error.
/// </summary>
bool HasError { get; }
/// <summary>
/// Creates a new <see cref="MessageType.Error"/> <see cref="MessageItem"/> with the specified format and <b>adds</b> to the underlying <see cref="IValidationContext"/>.
/// The friendly <see cref="Text"/> and <see cref="Value"/> are automatically passed as the first two arguments to the string formatter.
/// </summary>
/// <param name="format">The composite format string.</param>
/// <returns>A <see cref="MessageItem"/>.</returns>
MessageItem CreateErrorMessage(LText format);
/// <summary>
/// Creates a new <see cref="MessageType.Error"/> <see cref="MessageItem"/> with the specified format and additional values to be included in the text and <b>adds</b> to the underlying <see cref="IValidationContext"/>.
/// The friendly <see cref="Text"/> and <see cref="Value"/> are automatically passed as the first two arguments to the string formatter.
/// </summary>
/// <param name="format">The composite format string.</param>
/// <param name="values">The values that form part of the message text (<see cref="Text"/> and <see cref="Value"/> are automatically passed as the first two arguments to the string formatter).</param>
/// <returns>A <see cref="MessageItem"/>.</returns>
MessageItem CreateErrorMessage(LText format, params object?[] values);
/// <summary>
/// Creates a fully qualified property name for the name.
/// </summary>
/// <param name="name">The property name.</param>
string CreateFullyQualifiedPropertyName(string name);
/// <summary>
/// Creates a fully qualified JSON property name for the name.
/// </summary>
/// <param name="name">The property name.</param>
string CreateFullyQualifiedJsonPropertyName(string name);
}
}