How to use the @instructure/ui-prop-types.makeRequirable function in @instructure/ui-prop-types

To help you get started, we’ve selected a few @instructure/ui-prop-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github instructure / instructure-ui / packages / ui-i18n / src / I18nPropTypes.js View on Github external
`an ISO 8601 formatted string.`
      )
    }

    const iso8601regex = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/

    if (typeof propValue === 'string' && !propValue.match(iso8601regex)) {
      return new Error(
        `Invalid ${location} \`${propName}\` \`${propValue}\` supplied to \`${componentName}\`, expected ` +
          `an ISO 8601 formatted string.`
      )
    }
  }
}

I18nPropTypes.iso8601.isRequired = makeRequirable(I18nPropTypes.iso8601)

export default I18nPropTypes
export {
/**
 * ---
 * category: utilities/i18n
 * ---
 * @module I18nPropTypes
 * Custom I18n prop types for React components.
 */
  I18nPropTypes
}