potiuk commented on code in PR #58367: URL: https://github.com/apache/airflow/pull/58367#discussion_r2532011617
########## dev/breeze/src/airflow_breeze/utils/click_validators.py: ########## @@ -0,0 +1,52 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from __future__ import annotations + +import re +from datetime import datetime + +import click + + +def validate_planned_release_date(ctx: click.core.Context, param: click.core.Option, value: str) -> str: + """ + Validate that the date follows YYYY_MM_DD[_NN] format. + + :param ctx: Click context + :param param: Click parameter + :param value: The value to validate + :return: The validated value + :raises click.BadParameter: If the value doesn't match the required format + """ + if not value: + return value + + # Check if the format matches YYYY_MM_DD or YYYY_MM_DD_NN + pattern = r"^\d{4}_\d{2}_\d{2}(_\d{2})?$" + if not re.match(pattern, value): + raise click.BadParameter( + "Date must be in YYYY_MM_DD or YYYY_MM_DD_NN format (e.g., 2025_11_16 or 2025_11_16_01)" Review Comment: Fixed. I need to pay more attention to AI generated stuff and what I am asking it for :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
