All files / validator/yupSource index.js

33.33% Statements 4/12
0% Branches 0/8
33.33% Functions 1/3
30% Lines 3/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53                                3x 3x   3x                                                                  
import Lazy from './Lazy'
import Ref from './Reference'
import ValidationError from './ValidationError'
import array from './array'
import bool from './boolean'
import date from './date'
import getLocale from './getLocale'
import mixed from './mixed'
import number from './number'
import object from './object'
import setLocale from './setLocale'
import string from './string'
import isSchema from './util/isSchema'
import printValue from './util/printValue'
import reach from './util/reach'
 
let boolean = bool
let ref = (key, options) => new Ref(key, options)
 
let lazy = fn => new Lazy(fn)
 
function addMethod(schemaType, name, fn) {
  if (!schemaType || !isSchema(schemaType.prototype))
    throw new TypeError('You must provide a yup schema constructor function')
 
  if (typeof name !== 'string')
    throw new TypeError('A Method name must be provided')
  if (typeof fn !== 'function')
    throw new TypeError('Method function must be provided')
 
  schemaType.prototype[name] = fn
}
 
export {
  mixed,
  string,
  number,
  bool,
  boolean,
  date,
  object,
  array,
  ref,
  lazy,
  reach,
  isSchema,
  addMethod,
  setLocale,
  getLocale,
  printValue,
  ValidationError,
}