Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YANG statement "must" is not validated by GO structs Validate function #1004

Open
oleg8000 opened this issue Jan 14, 2025 · 0 comments
Open

Comments

@oleg8000
Copy link

YANG model:

module my-module {
	namespace "my-module";
	prefix my;

	container configuration {
		container values {
			leaf val {
				type int32;
			}
			must '. >= (../res-values/minimum) and . <= (../res-values/maximum)';
		}

		container res-values {
			leaf minimum {
				type int32;
			}
			leaf maximum {
				type int32;
			}
		}
	}
}

Code:

func main() {
	v := int32(50)
	minimum := int32(0)
	maximum := int32(10)
	resValues := schema.MyModule_Configuration_ResValues{Minimum: &minimum, Maximum: &maximum}
	values := schema.MyModule_Configuration_Values{Val: &v}
	config := schema.MyModule_Configuration{ResValues: &resValues, Values: &values}
	err := config.Validate()
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println("Validation successful")
	}
}

Output is "Validation successful".

ygot version: github.com/openconfig/ygot v0.29.20

Thank you for attention!

@oleg8000 oleg8000 changed the title YANG statement "must" is not validating by GO structs Validate function YANG statement "must" is not validated by GO structs Validate function Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant