github.com/blend/go-sdk@v1.20220411.3/validate/return_first.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package validate
     9  
    10  // ReturnFirst runs a list of validators and returns
    11  // the first validator to error (if there is one).
    12  func ReturnFirst(validators ...Validator) error {
    13  	var err error
    14  	for _, validator := range validators {
    15  		if err = validator(); err != nil {
    16  			return err
    17  		}
    18  	}
    19  	return nil
    20  }