-
Notifications
You must be signed in to change notification settings - Fork 5
/
IEnvValidator.cs
55 lines (48 loc) · 2.37 KB
/
IEnvValidator.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
using System;
using System.Collections.Generic;
using System.Text;
namespace DotEnv.Core;
/// <summary>
/// Represents the validator of the required keys.
/// </summary>
public interface IEnvValidator
{
/// <param name="result">The result contains the errors found by the validator.</param>
/// <inheritdoc cref="Validate()" />
void Validate(out EnvValidationResult result);
/// <summary>
/// Validates whether the required keys are present in the application.
/// </summary>
/// <exception cref="InvalidOperationException">The required keys are not specified with the <c>SetRequiredKeys</c> method.</exception>
/// <exception cref="RequiredKeysNotPresentException">
/// If the required keys are not present in the application.
/// This exception is not thrown if the <see cref="IgnoreException" /> method is invoked.
/// </exception>
void Validate();
/// <summary>
/// Sets the required keys by means of a string collection.
/// </summary>
/// <param name="keys">The required keys to set.</param>
/// <exception cref="ArgumentNullException"><c>keys</c> is <c>null</c>.</exception>
/// <exception cref="ArgumentException">The length of the <c>keys</c> list is zero.</exception>
/// <returns>An instance implementing the fluent interface.</returns>
IEnvValidator SetRequiredKeys(params string[] keys);
/// <summary>
/// Sets the required keys by means of the properties of a class or struct.
/// </summary>
/// <typeparam name="TKeys">The type with the required keys.</typeparam>
/// <returns>An instance implementing the fluent interface.</returns>
IEnvValidator SetRequiredKeys<TKeys>();
/// <summary>
/// Sets the required keys by means of the properties of a class or struct.
/// </summary>
/// <param name="keysType">The type with the required keys.</param>
/// <exception cref="ArgumentNullException"><c>keysType</c> is <c>null</c>.</exception>
/// <returns>An instance implementing the fluent interface.</returns>
IEnvValidator SetRequiredKeys(Type keysType);
/// <summary>
/// Disables/ignores <see cref="RequiredKeysNotPresentException" />. This method tells the validator not to throw an exception when it encounters one or more errors.
/// </summary>
/// <returns>An instance implementing the fluent interface.</returns>
IEnvValidator IgnoreException();
}