// Valid returns whether the Currency is valid according to the OFX spec
189771
func (c Currency) Valid() (bool, error) {
	if c.CurRate.IsInt() && c.CurRate.Num().Int64() == 0 {
		return false, errors.New("CurRate may not be zero")
	} else if ok, err := c.CurSym.Valid(); !ok {
		return false, err
	}
	return true, nil
}
477083
func (t Transaction) Valid(version ofxVersion) (bool, error) {
	var emptyDate Date
	if !t.TrnType.Valid() || t.TrnType == TrnTypeHold {
		return false, errors.New("Transaction.TrnType invalid")
	} else if t.DtPosted.Equal(emptyDate) {
		return false, errors.New("Transaction.DtPosted not filled")
	} else if len(t.FiTID) == 0 {
		return false, errors.New("Transaction.FiTID empty")
	} else if len(t.CorrectFiTID) > 0 && t.CorrectAction.Valid() {
		return false, errors.New("Transaction.CorrectFiTID nonempty but CorrectAction invalid")
	} else if len(t.Name) > 0 && t.Payee != nil {
		return false, errors.New("Only one of Transaction.Name and Payee may be specified")
	}
	if t.Payee != nil {
		if ok, err := t.Payee.Valid(); !ok {
			return false, err
		}
	}
	if t.BankAcctTo != nil && t.CCAcctTo != nil {
		return false, errors.New("Only one of Transaction.BankAcctTo and CCAcctTo may be specified")
	} else if t.BankAcctTo != nil {
		if ok, err := t.BankAcctTo.Valid(); !ok {
			return false, err
		}
	} else if t.CCAcctTo != nil {
		if ok, err := t.CCAcctTo.Valid(); !ok {
			return false, err
		}
	}
	if version < OfxVersion220 && len(t.ImageData) > 0 {
		return false, errors.New("Transaction.ImageData only supportd for OFX > 220")
	} else if len(t.ImageData) > 2 {
		return false, errors.New("Only 2 of ImageData allowed in Transaction")
	}
	var ok1, ok2 bool
	if t.Currency != nil {
		ok1, _ = t.Currency.Valid()
	}
	if t.OrigCurrency != nil {
		ok2, _ = t.OrigCurrency.Valid()
	}
	if ok1 && ok2 {
		return false, errors.New("Currency and OrigCurrency both supplied for Pending Transaction, only one allowed")
	}
	return true, nil
}
976580
func (dbp *Process) Valid() (bool, error) {
	if dbp.detached {
		return false, &proc.ProcessDetachedError{}
	}
	if dbp.exited {
		return false, &proc.ErrProcessExited{Pid: dbp.Pid()}
	}
	return true, nil
}
1251720
func (p *Provider) Valid(hash, plain []byte) bool {
	if !prefixValid(hash) {
		return false
	}

	_, params, saltBytes, expectedKey, err := mcf.Decode(hash, providerName)
	if err != nil {
		return false
	}
	hashParams := paramsFromMCF([]byte(params))

	key, _ := scrypt.Key(plain, saltBytes, hashParams.n, hashParams.r, hashParams.p, hashParams.keyLen)

	return subtle.ConstantTimeCompare(key, expectedKey) == 1
}
1239220
func (ut UserType) Valid() (err error) {
	switch ut {
	case Owner: // 1
	case Member: // 2
	default:
		err = ErrInvalidUserType
	}

	return err
}
114509
func (l LevelInfo) Valid() bool {
	return level.IsValidPriority(l.Default) && level.IsValidPriority(l.Threshold)
}
1206990
func (t PendingTransaction) Valid() (bool, error) {
	var emptyDate Date
	if !t.TrnType.Valid() {
		return false, errors.New("PendingTransaction.TrnType invalid")
	} else if t.DtTran.Equal(emptyDate) {
		return false, errors.New("PendingTransaction.DtTran not filled")
	} else if len(t.Name) == 0 {
		return false, errors.New("PendingTransaction.Name empty")
	}
	ok1, _ := t.Currency.Valid()
	ok2, _ := t.OrigCurrency.Valid()
	if ok1 && ok2 {
		return false, errors.New("Currency and OrigCurrency both supplied for Pending Transaction, only one allowed")
	}
	return true, nil
}
321542
func (p *Provider) Valid(hash, plain []byte) bool {
	return gobcrypt.CompareHashAndPassword(hash, plain) == nil
}
990575
func (t Tile) Valid() bool {
	maxIndex := uint32(1) << uint32(t.Z)
	return t.X < maxIndex && t.Y < maxIndex
}
382588
func valid(authorization []string) bool {
	if len(authorization) < 1 {
		return false
	}
	token := strings.TrimPrefix(authorization[0], "Bearer ")
	// Perform the token validation here. For the sake of this example, the code
	// here forgoes any of the usual OAuth2 token validation and instead checks
	// for a token matching an arbitrary string.
	return token == "some-secret-token"
}
678337
func (p *Process) Valid() (bool, error) {
	if p.detached {
		return false, &proc.ProcessDetachedError{}
	}
	if p.exited {
		return false, &proc.ErrProcessExited{Pid: p.Pid()}
	}
	return true, nil
}
509864
func (l TransactionList) Valid(version ofxVersion) (bool, error) {
	var emptyDate Date
	if l.DtStart.Equal(emptyDate) {
		return false, errors.New("TransactionList.DtStart not filled")
	} else if l.DtEnd.Equal(emptyDate) {
		return false, errors.New("TransactionList.DtEnd not filled")
	}
	for _, t := range l.Transactions {
		if ok, err := t.Valid(version); !ok {
			return false, err
		}
	}

	return true, nil
}
1127189
func (c StandardClaims) Valid() error {
	vErr := new(ValidationError)
	now := TimeFunc().Unix()

	// The claims below are optional, by default, so if they are set to the
	// default value in Go, let's not fail the verification for them.
	if c.VerifyExpiresAt(now, false) == false {
		delta := time.Unix(now, 0).Sub(time.Unix(c.ExpiresAt, 0))
		vErr.Inner = fmt.Errorf("token is expired by %v", delta)
		vErr.Errors |= ValidationErrorExpired
	}

	if c.VerifyIssuedAt(now, false) == false {
		vErr.Inner = fmt.Errorf("Token used before issued")
		vErr.Errors |= ValidationErrorIssuedAt
	}

	if c.VerifyNotBefore(now, false) == false {
		vErr.Inner = fmt.Errorf("token is not valid yet")
		vErr.Errors |= ValidationErrorNotValidYet
	}

	if vErr.valid() {
		return nil
	}

	return vErr
}
1187773
func (s *Status) Valid() (bool, error) {
	switch s.Severity {
	case "INFO", "WARN", "ERROR":
	default:
		return false, errors.New("Invalid STATUS>SEVERITY")
	}

	if arr, ok := statusMeanings[s.Code]; ok {
		if arr[1] != string(s.Severity) {
			return false, errors.New("Unexpected SEVERITY for STATUS>CODE")
		}
	} else {
		return false, errors.New("Unknown OFX status code")
	}

	return true, nil
}
620094
func (bb BBox) Valid() bool {
	if bb == nil {
		return false
	}

	return len(bb) >= 4 && len(bb)%2 == 0
}
467569
func (s Status) Valid() error {
	switch s {
	case Active, Inactive:
		return nil
	default:
		return &Error{
			Code: EInvalid,
			Msg:  fmt.Sprintf("invalid status: must be %v or %v", Active, Inactive),
		}
	}
}
879584
func (level LevelType) valid() bool {
	if TRACE > level || CRITICAL < level {
		return false
	}
	return true
}