FAQ

  • GitHub GitHub Repo stars
  • Discord Discord Server
  • ✨ New! Try the OpenAPI Doctor ✨ The OpenAPI Doctor

    length


    length will check that a value meets a minimum or a maximum length (or both).

    How do I use this function?

    This function is configured by the following functionOptions. Essentially min and max determine if those limits are checked.

    NAME TYPE REQUIRED? DESCRIPTION
    min integer no The minimum floor you want to check for
    max integer no The maximum ceiling you want to check for

    You need to set at least one of these properties.

    Example ruleset configurations

    check-the-length:
      description: "Check the length of 'name' is at least 5 characters long"
      type: style
      recommended: true
      given: $.tags[*]
      then:
        field: name
        function: "length"
        functionOptions:
          min: 5
    
    check-the-range:
      description: "Check the 'name' is at least three and less than 10 chars long"
      type: style
      recommended: true
      given: $.tags[*]
      then:
        field: name
        function: "length"
        functionOptions:
          min: 5
          max: 10
    

    View Spectral Equivalent


    View Function Source