title: Adding restrictions to validate json data send to Rails API
body: <p>So I've been creating a Rails API (A school project) and everything works fine, but now I want to add some restrictions to the POST endpoint.
  So here is my create endpoint when I'm going to foo.com/api/v1/slogans :</p>
  
  <pre><code>def create
    slogan = Slogan.new(slogan_params)
    if(slogan.save)
      render json: {
        status: 'SUCCESS',
        message: 'Saved slogan',
        data: slogan
      }, status: :ok
    else 
      render json: {
        status: 'ERROR',
        message: 'Slogan not saved',
        data: slogan.error
      }, status: :unprocessable_entity
    end
  end
  </code></pre>
  
  <p>And these are my slogan_params : </p>
  
  <pre><code>private def slogan_params
    params.permit(:firstname, :lastname, :email, :slogan)
  end
  </code></pre>
  
  <p>Now how do I add restrictions to this, for example a character limit? I've already added one on my front end but I want to be sure that even if the front end is manipulated that the data don't get submitted if valid.</p>
  
  <p>I thought about adding something in <code>def create</code> but not sure if that is the way to do it.</p>