If(
Len(Self.Text) > 0;
If(
!("/" in Self.Text) && Len(Self.Text) = 8 && IsNumeric(Self.Text);
UpdateContext({varDate: Left(Self.Text; 2) & "/" & Mid(Self.Text; 3; 2) & "/" & Right(Self.Text; 4)});;
Reset(Self);
UpdateContext({varDate: Self.Text})
);;
With(
{dateParts: Split(varDate; "/")};
With(
{
day: Value(First(dateParts).Value);
month: Value(Index(dateParts; 2).Value);
year: Value(Last(dateParts).Value);
enteredDate: DateValue(varDate; "fr-FR");
minValidDate: DateAdd(Today(); 3; TimeUnit.Months);
maxValidDate: DateAdd(Today(); 3; TimeUnit.Years)
};
With(
{
_ErrorDates:
month = 1 && day > 31 ||
month = 2 && day > If(Mod(year; 4) = 0; 29; 28) ||
month = 3 && day > 31 ||
month = 4 && day > 30 ||
month = 5 && day > 31 ||
month = 6 && day > 30 ||
month = 7 && day > 31 ||
month = 8 && day > 31 ||
month = 9 && day > 30 ||
month = 10 && day > 31 ||
month = 11 && day > 30 ||
month = 12 && day > 31;
_ErrorFormat: !IsMatch(varDate; "^\d{2}/\d{2}/\d{4}$");
_ErrorMax: enteredDate > maxValidDate;
_ErrorMin: enteredDate < minValidDate
};
With(
{_Error: _ErrorDates || _ErrorFormat || _ErrorMax || _ErrorMin};
If(
_Error;
Notify(
If(
_ErrorDates;
"Date invalide.";
_ErrorFormat;
"Date invalide. Veuillez entrer une date au format JJ/MM/AAAA.";
_ErrorMax;
"La date doit être inférieure à 3 ans.";
_ErrorMin;
"La date doit être supérieure à 3 mois."
);
NotificationType.Error
);;
UpdateContext({varDate: ""});;
Reset(Self)
)
)
)
)
)
)
If(
"/" in Self.Text;
With( {dateParts: Split(Self.Text; "/")}; With( { day: Value(First(dateParts).Value); month: Value(Index(dateParts; 2).Value); year: Value(Last(dateParts).Value); enteredDate: DateValue(Self.Text; "fr-FR"); minValidDate: DateAdd(Today(); 3; TimeUnit.Months); maxValidDate: DateAdd(Today(); 3; TimeUnit.Years) }; With( { _ErrorDates: month = 1 && day > 31 || month = 2 && day > If(Mod(year; 4) = 0; 29; 28) || month = 3 && day > 31 || month = 4 && day > 30 || month = 5 && day > 31 || month = 6 && day > 30 || month = 7 && day > 31 || month = 8 && day > 31 || month = 9 && day > 30 || month = 10 && day > 31 || month = 11 && day > 30 || month = 12 && day > 31; _ErrorFormat: !IsMatch(Self.Text; "^\d{2}/\d{2}/\d{4}$"); _ErrorMax: enteredDate > maxValidDate; _ErrorMin: enteredDate < minValidDate }; With( {_Error: _ErrorDates || _ErrorFormat || _ErrorMax || _ErrorMin}; If( _Error; Notify( If( _ErrorDates; "Date invalide."; _ErrorFormat; "Date invalide. Veuillez entrer une date au format JJ/MM/AAAA."; _ErrorMax; "La date doit être inférieure à 3 ans."; _ErrorMin; "La date doit être supérieure à 3 mois." ); NotificationType.Error );; Reset(Self) ) ) ) )
) )