Restructuration
This commit is contained in:
22
Validation/Age.cs
Normal file
22
Validation/Age.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Hermes.Validation {
|
||||
class Age : ValidationRule {
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
|
||||
if(string.IsNullOrEmpty((string) value)) {
|
||||
return ValidationResult.ValidResult;
|
||||
}
|
||||
|
||||
try {
|
||||
if(Int32.Parse((string) value) <= 0) {
|
||||
throw new ArgumentException();
|
||||
}
|
||||
} catch(Exception) {
|
||||
return new ValidationResult(false, "Ce champ doit contenir un age au format numérique");
|
||||
}
|
||||
return ValidationResult.ValidResult;
|
||||
}
|
||||
}
|
||||
}
|
13
Validation/MandatoryString.cs
Normal file
13
Validation/MandatoryString.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Hermes.Validation {
|
||||
class MandatoryString : ValidationRule {
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
|
||||
if(string.IsNullOrWhiteSpace((string) value)) {
|
||||
return new ValidationResult(false, "Ce champ est obligatoire");
|
||||
}
|
||||
return ValidationResult.ValidResult;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user