Terraform Plugin Framework: Validation for nested attributes

I am using terraform-plugin-framework for the provider development. Below is the schema.
The attributes are optional/computed

> Blockquote
contact = {
      primary = {
          "attr1" = "value1"
          "attr2" = "value2"
     }
     secondary = {
        "attr1" = "value1"
        "attr2" = "value2"
     }
 }
      

I dont want to allow below configs:

 contact = {}

or 

contact = {
      primary = {}
      secondary = {}
}

Is there any provision to add such validation ?

field contact cannot be null?

Basically, if you are specifying contact, you should specify Primary or Secondary details.

contact = null

or ommit the all field

I am looking for adding the validation in the resource itself.

I’m questioning this because, if the field is optional by nature, it is understood that when it’s null, it has the same effect as an empty object (the contact fields without being filled in).

Once the field is filled in, it will have to adhere to a contract that requires filling in two mandatory fields called primary and secondary.

Does that make sense to you?

All the fields are optional/computed including primary/secondary.

When empty object is provided (contact = {}), I believe it is considered as not null by the plugin framework.

you can use a custom validation