package com.friday.custody.utils;

import lombok.AllArgsConstructor;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

@AllArgsConstructor
public class DateValidatorUsingDateFormat implements DateValidator{

    private final DateTimeFormatter dateTimeFormatter;

    /**
     * @param dateStr
     * @return
     */
    @Override
    public boolean isValid(String dateStr) {
        try {
            LocalDate.parse(dateStr, dateTimeFormatter);
        }catch (DateTimeParseException e){
            return false;
        }
        return true;
    }
}
