Skip to content

Commit aea85a6

Browse files
committed
feat: add validator method to handle ByteEncryptionParameters null checks
1 parent 420e464 commit aea85a6

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

src/Helpers/Validators.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using SafeCrypt.src.Encryption.AesEncryption.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace SafeCrypt.src.Helpers
7+
{
8+
public static class Validators
9+
{
10+
/// <summary>
11+
/// Validates that the specified ByteEncryptionParameters instance is not null
12+
/// and that its required properties (Data, SecretKey, IV) are not null.
13+
/// </summary>
14+
/// <param name="parameters">The ByteEncryptionParameters instance to validate.</param>
15+
/// <exception cref="ArgumentNullException">
16+
/// Thrown if the specified parameters instance is null or if any of its required properties are null.
17+
/// </exception>
18+
public static void ValidateNotNull(ByteEncryptionParameters parameters)
19+
{
20+
if (parameters == null)
21+
{
22+
throw new ArgumentNullException(nameof(parameters), "ByteEncryptionParameters instance cannot be null.");
23+
}
24+
25+
if (parameters.Data == null)
26+
{
27+
throw new ArgumentNullException(nameof(parameters.Data), "Data property cannot be null.");
28+
}
29+
30+
if (parameters.SecretKey == null)
31+
{
32+
throw new ArgumentNullException(nameof(parameters.SecretKey), "SecretKey property cannot be null.");
33+
}
34+
35+
if (parameters.IV == null)
36+
{
37+
throw new ArgumentNullException(nameof(parameters.IV), "IV property cannot be null.");
38+
}
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)