Errors

go-bs returns errors, not panics (except MustParse, which documents that it panics). Every validation error wraps one of these sentinels.

SentinelReturned when
ErrInvalidYearA BS year is outside MinBSYear..MaxBSYear.
ErrInvalidMonthA BS month is not in the range 1..12.
ErrInvalidDayA BS day is not a valid day of the given month — either out of the generic 1..32 bound, or greater than the actual days in that month/year.
ErrOutOfRangeAn AD date falls outside the Gregorian range corresponding to MinBSYear..MaxBSYear.
ErrInvalidFormatA string passed to Parse, UnmarshalText or Scan is not shaped like "YYYY-MM-DD".
ErrInvalidDateOrderAge's birthBS is after its todayBS.

Checking for a specific error

Every returned error wraps one of the sentinels above via fmt.Errorf's %w verb, so use errors.Is rather than comparing strings or equality directly. The one exception is Scan given an unsupported source type (e.g. an int), which returns a plain error that wraps no sentinel.

_, err := bs.NewDate(2080, 1, 32)
if errors.Is(err, bs.ErrInvalidDay) {
	// handle specifically
}