-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4afb810
commit ca02113
Showing
79 changed files
with
1,065 additions
and
1,065 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
samples/Mollie.WebApplication.Blazor/Framework/Validators/StaticStringListAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Reflection; | ||
|
||
namespace Mollie.WebApplication.Blazor.Framework.Validators; | ||
namespace Mollie.WebApplication.Blazor.Framework.Validators; | ||
|
||
public class StaticStringListAttribute : ValidationAttribute { | ||
private readonly Type _staticClass; | ||
|
||
public StaticStringListAttribute(Type staticClass) { | ||
this._staticClass = staticClass; | ||
_staticClass = staticClass; | ||
} | ||
|
||
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { | ||
IEnumerable<string> validValues = this._staticClass | ||
IEnumerable<string> validValues = _staticClass | ||
.GetFields(BindingFlags.Static | BindingFlags.Public) | ||
.Select(x => x.GetValue(null).ToString()); | ||
|
||
if (validValues.Contains(value)) { | ||
return ValidationResult.Success; | ||
} | ||
|
||
return new ValidationResult($"The value \"{value}\" is invalid"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.