UNPKG

2.48 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import printValue from './util/printValue';
3export var mixed = {
4 default: '${path} is invalid',
5 required: '${path} is a required field',
6 oneOf: '${path} must be one of the following values: ${values}',
7 notOneOf: '${path} must not be one of the following values: ${values}',
8 notType: function notType(_ref) {
9 var path = _ref.path,
10 type = _ref.type,
11 value = _ref.value,
12 originalValue = _ref.originalValue;
13 var isCast = originalValue != null && originalValue !== value;
14 var msg = path + " must be a `" + type + "` type, " + ("but the final value was: `" + printValue(value, true) + "`") + (isCast ? " (cast from the value `" + printValue(originalValue, true) + "`)." : '.');
15
16 if (value === null) {
17 msg += "\n If \"null\" is intended as an empty value be sure to mark the schema as `.nullable()`";
18 }
19
20 return msg;
21 },
22 defined: '${path} must be defined'
23};
24export var string = {
25 length: '${path} must be exactly ${length} characters',
26 min: '${path} must be at least ${min} characters',
27 max: '${path} must be at most ${max} characters',
28 matches: '${path} must match the following: "${regex}"',
29 email: '${path} must be a valid email',
30 url: '${path} must be a valid URL',
31 uuid: '${path} must be a valid UUID',
32 trim: '${path} must be a trimmed string',
33 lowercase: '${path} must be a lowercase string',
34 uppercase: '${path} must be a upper case string'
35};
36export var number = {
37 min: '${path} must be greater than or equal to ${min}',
38 max: '${path} must be less than or equal to ${max}',
39 lessThan: '${path} must be less than ${less}',
40 moreThan: '${path} must be greater than ${more}',
41 notEqual: '${path} must be not equal to ${notEqual}',
42 positive: '${path} must be a positive number',
43 negative: '${path} must be a negative number',
44 integer: '${path} must be an integer'
45};
46export var date = {
47 min: '${path} field must be later than ${min}',
48 max: '${path} field must be at earlier than ${max}'
49};
50export var boolean = {};
51export var object = {
52 noUnknown: '${path} field has unspecified keys: ${unknown}'
53};
54export var array = {
55 min: '${path} field must have at least ${min} items',
56 max: '${path} field must have less than or equal to ${max} items'
57};
58export default _extends(Object.create(null), {
59 mixed: mixed,
60 string: string,
61 number: number,
62 date: date,
63 object: object,
64 array: array,
65 boolean: boolean
66});
\No newline at end of file