JAVASCRIPT   64

adaptInputValidator.js

Guest on 29th July 2021 03:15:29 PM

  1. /**
  2.  * Adapt a legacy inputValidator for use with expectRejections=false
  3.  */
  4. export const adaptInputValidator = (legacyValidator) => {
  5.   return function adaptedInputValidator (inputValue, extraParams) {
  6.     return legacyValidator.call(this, inputValue, extraParams)
  7.       .then(() => undefined, validationMessage => validationMessage)
  8.   }
  9. }

Raw Paste


Login or Register to edit or fork this paste. It's free.