title: how do i enforce the proper data types on gofiber golang from POST data from frontend?
body: <p>I am receiving the following POST request json data from react frontend</p>
  <pre><code>{
      &quot;field_one&quot;: &quot;first&quot;,
      &quot;field_two&quot;: &quot;second&quot;,
      &quot;field_three&quot;: &quot;3.00&quot;
  }
  
  </code></pre>
  <p>but i want golang to convert it to this before processing the request</p>
  <pre><code>{
      &quot;field_one&quot;: &quot;first&quot;,
      &quot;field_two&quot;: &quot;second&quot;,
      &quot;field_three&quot;: 3.00
  }
  </code></pre>
  <p>I want to convert the <code>field_three</code> from string to <strong>float64</strong>, but i am unable to have golang accept the string and process the proper data type</p>
  <p>here is my golang function processing the POST request data</p>
  <pre><code>func PostCreate(c *fiber.Ctx) error {
      
      type PostCreateData struct {
          fieldOne       string  `json:&quot;field_one&quot; form:&quot;field_one&quot; validate:&quot;required&quot;`
          fieldTwo       string  `json:&quot;field_two&quot; form:&quot;field_two&quot; validate:&quot;required&quot;`
          fieldThree     float64 `json:&quot;field_three&quot; form:&quot;field_three&quot; validate:&quot;required&quot;`
      }
  
      data := PostCreateCreateData{}
  
      if err := c.BodyParser(&amp;data); err != nil {
          return err
      }
  
      validate := validator.New()
          if err := validate.Struct(data); err != nil {
          return err
      }
  
      postCreate := models.PostCreate{
          fieldOne:         data.fieldOne,
          fieldTwo:         data.fieldTwo,
          fieldThree:       float64(data.fieldThree),
      }
  
      database.DB.Create(&amp;postCreate)
      return c.JSON(postCreate)
  }
  
  </code></pre>
  <p>Currently the request is not getting processed because the wrong data type for <code>field_three</code> which is supposed to be <strong>float64</strong> but frontend is sending everything as string</p>
  <p>What steps am i missing here?</p>