const testJWTPayload = function testJWTPayload(props, propName) {
  //if (!props[propName] && isRequired === true) return new Error('JWTPayload is required')
  if (props[propName]) {
    const payload = props[propName]
    if (typeof payload !== 'object') return new Error('Type of JWTPayload must be "object"')
    if (typeof payload.userID !== 'string') {
      return new Error('JWTPayload must have a key "userID" containing a string')
    }
    if (typeof payload.services !== 'object') {
      return new Error('JWTPayload must have a key "services" containing an object')
    } else {
      for (const service in payload.services) {
        if (typeof payload.services[service].token !== 'string') {
          return new Error('Each service in a JWTPayload must contain a key "token"')
        }
        if (typeof payload.services[service].username !== 'string') {
          return new Error('Each service in a JWTPayload must contain a key "username"')
        }
      }
    }
  } else return null
}

const JWTPayload = function JWTPayload(props, propName, componentName) {
  return testJWTPayload(props, propName, componentName, false)
}

JWTPayload.isRequired = function JWTPayloadIsRequired(props, propName, componentName) {
  if (typeof props[propName] === 'undefined') {
    return new Error(`${propName} in ${componentName} may not be undefined`)
  } else {
    return testJWTPayload(props, propName, componentName, true)
  }
}

JWTPayload.allowNull = function JWTPayloadIsRequired(props, propName, componentName) {
  return testJWTPayload(props, propName, componentName, true)
}

export default JWTPayload

@@ -1,12 +1,51 @@
+import %7B oneLine %7D from 'common-tags'%0A%0A
 const testJW
@@ -98,103 +98,26 @@
 Name
-) %7B%0A  //if (!props%5BpropName%5D && isRequired === true) return new Error('JWTPayload is required')
+, componentName) %7B
 %0A  i
@@ -210,16 +210,24 @@
 object')
+ %7B%0A     
  return 
@@ -240,27 +240,45 @@
 ror(
-'Type of JWTPayload
+%60Prop $%7BpropName%7D in $%7BcomponentName%7D
  mus
@@ -286,18 +286,27 @@
  be 
-%22
+an 
 object
-%22')
+. %60)%0A    %7D
 %0A   
@@ -367,35 +367,76 @@
 n new Error(
-'JWTPayload
+oneLine%60Prop $%7BpropName%7D in $%7BcomponentName%7D%0A       
  must have a
@@ -468,17 +468,19 @@
 a string
-'
+. %60
 )%0A    %7D%0A
@@ -554,19 +554,60 @@
 ror(
-'JWTPayload
+oneLine%60Prop $%7BpropName%7D in $%7BcomponentName%7D%0A       
  mus
@@ -650,17 +650,19 @@
 n object
-'
+. %60
 )%0A    %7D 
@@ -866,16 +866,18 @@
  %22token%22
+. 
 ')%0A     
@@ -1037,16 +1037,18 @@
 sername%22
+. 
 ')%0A     
@@ -1386,16 +1386,23 @@
 w Error(
+oneLine
 %60$%7BpropN
@@ -1446,16 +1446,82 @@
 ndefined
+.%0A      Did you mean to use JWTPayload.allowNull in the PropTypes?
 %60)%0A  %7D e
@@ -1567,37 +1567,16 @@
 propName
-, componentName, true
 )%0A  %7D%0A%7D%0A

Clarify JWTPayload prop validation error messages