sheet-historical-data-conve.../utility/validate.go

38 lines
589 B
Go

package utility
import (
"github.com/360EntSecGroup-Skylar/excelize/v2"
)
type Validator interface {
Validate() bool
}
type XLXSDateValidator struct {
Date string
}
func (dv *XLXSDateValidator) Validate() bool {
if IsNumeric(dv.Date) {
_, err := excelize.ExcelDateToTime(StringToFloat(dv.Date), false)
if err == nil {
return true
}
}
return false
}
type CurrencyAmountValidator struct {
Number string
}
func (dv *CurrencyAmountValidator) Validate() bool {
return IsNumeric(dv.Number)
}
func ValidateData(validator Validator) bool {
return validator.Validate()
}