dealancer / validate

Go struct validation
MIT License
60 stars 6 forks source link

struct values getting cached - error not occuring once struct updated and again removed required values #4

Open rajagopalanrg opened 4 years ago

rajagopalanrg commented 4 years ago

Hi,

I am using revel framework and this is my struct

type MVMVARS struct { Location string json:"location" validate:"empty=false" VMName string json:"vm_name" validate:"empty=false" ResourceGroupName string json:"rg_name" validate:"empty=false" AdminUsername string json:"admin_username" validate:"empty=false" AdminPassword string json:"admin_password" validate:"empty=false" VMSku string json:"vm_sku" validate:"empty=false" VMSize string json:"vm_size" validate:"empty=false" OSDataDiskSizeInGB int json:"osdatadisksizeingb" DataDisks []int json:"data_disks" BootDiagStorageAccount string json:"boot_diag_storage" VnetName string json:"vnet_name" validate:"empty=false" SubnetName string json:"subnet_name" validate:"empty=false" AvailabilitySet string json:"availability_set" IdentityID []string json:"identity_id" SubscriptionID string json:"subscription_Id" validate:"empty=false" }

I am getting input to this struct through postman. When the request is received to controller, it binds the params to this struct.

c.Params.BindJSON(&mvm)

I did a validation first without values for vnetname and subnetname and I can catch the errors. The next time I supplied vnet name and I get error for subnetname. When I removed vnet and provided subnetname, I didn't get error for vnet. Also I tried removing both vnet and subnet and I still don't get the validation errors. I can see that the inputs I gave for the last time is still being used instead of the new ones.

Could you help us to identify this issue.

dealancer commented 4 years ago

@rajagopalanrg, were you able to resolve it?