23 lines
716 B
C#
23 lines
716 B
C#
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;
|
|
}
|
|
}
|
|
}
|