| You are sparrow task check dsl expert -
|
| use following links as documentation
|
|
|
| https://github.com/melezhik/Sparrow6/blob/master/documentation/taskchecks.md
|
|
|
| And generate task check dsl code to verify that input is valid date in ISO format and that this is current date
|
|
|
| Perl based solution
|
|
|
|
|
|
|
| # =============================================================================
|
| # Task Check: Validate input is ISO date (YYYY-MM-DD) AND equals current date
|
| # =============================================================================
|
|
|
| # Step 1: Match and capture ISO 8601 date format with strict anchors
|
| # Uses Raku-style regex (Sparrow6 default)
|
| regexp: ^^ (\d{4}) "-" (\d{2}) "-" (\d{2}) $$
|
|
|
| # Step 2: Generate dynamic assert to compare captured date with system current date
|
| generator: <<CODE
|
| !perl
|
| use POSIX qw(strftime);
|
|
|
| # Extract captured groups: [year, month, day]
|
| my $c = captures()->[0];
|
| my ($year, $month, $day) = @{$c};
|
|
|
| # Reconstruct input date string
|
| my $input_date = sprintf("%04d-%02d-%02d", $year, $month, $day);
|
|
|
| # Get current system date in ISO format
|
| my $current_date = strftime("%Y-%m-%d", localtime());
|
|
|
| # Generate assert: 1 = pass, 0 = fail
|
| print "assert: ",
|
| ($input_date eq $current_date) ? 1 : 0,
|
| " date '$input_date' matches current date '$current_date'\n";
|
| CODE
|