package com.example.mystictale.resources.components.dateComponents

import android.os.Build
import androidx.annotation.RequiresApi
import java.time.LocalDate
import java.time.format.DateTimeFormatter


@RequiresApi(Build.VERSION_CODES.O)
fun ValidationDate(
    dateOfBirth: String,
    formatter: DateTimeFormatter
): Boolean {

    if (dateOfBirth.isEmpty()) {
        return true
    } else if (dateOfBirth.length < 8) {
        return true
    } else if (!isDateValid(dateOfBirth)) {
        return true
    } else if (LocalDate.parse(dateOfBirth, formatter) > LocalDate.now()) {
        return true
    }
    return false
}