I work with yaml and spring boot and I will make a method which will be validate my field.
- If field value non null I have to return this value.
- If field value null I have to load default value from yaml file based on fieldName.
My method example:
@PropertySource("classpath:defaultValue.yml")
public final class ValidateAttributeValue {
public static String validateAttributeValue(String attributeName, String attributeValue){
if (nonNull(attributeValue)){
return attributeValue;
}
//here I have to return default value from file based on attributeName
}
yaml file:
values:
field: defaultValue
field1: defaultValue1
field2: defaultValue2
field3: defaultValue3
How can it be implemented in Spring boot + yaml?