func (f FeatureFlag) Validate() error {
	// Validate percentage
	if f.Percentage < 0 || f.Percentage > 100 {
		return fmt.Errorf("Percentage must be between 0 and 100")
	}

	// Validate key
	if len(f.Key) < 3 || len(f.Key) > 50 {
		return fmt.Errorf("Feature key must be between 3 and 50 characters")
	}

	if !regexp.MustCompile(`^[a-z0-9_]*$`).MatchString(f.Key) {
		return fmt.Errorf("Feature key must only contain digits, lowercase letters and underscores")
	}
	return nil
}
// Self validate the properties of a feature flag
Self validate the properties of a feature flag
// Self validate the properties of a feature flag
func (f FeatureFlag) Validate() error {
	if f.Percentage < 0 || f.Percentage > 100 {
		return fmt.Errorf("Percentage must be between 0 and 100")
	}
	if len(f.Key) < 3 || len(f.Key) > 50 {
		return fmt.Errorf("Feature key must be between 3 and 50 characters")
	}
	if !regexp.MustCompile(`^[a-z0-9_]*$`).MatchString(f.Key) {
		return fmt.Errorf("Feature key must only contain digits, lowercase letters and underscores")
	}
	return nil
}
func ( f FeatureFlag ) Validate ( ) error { if f . Percentage < 0 || f . Percentage > 100 { return fmt . Errorf ( " " ) } if len ( f . Key ) < 3 || len ( f . Key ) > 50 { return fmt . Errorf ( " " ) } if ! regexp . MustCompile ( `^[a-z0-9_]*$` ) . MatchString ( f . Key ) { return fmt . Errorf ( " " ) } return nil }
Self validate the properties of a feature flag
Self validate the properties of a feature flag
// Validate percentage // Validate key