Skip to content

Commit 04e1111

Browse files
author
yangfan36
committed
fix
1 parent 92510fb commit 04e1111

File tree

5 files changed

+93
-4
lines changed

5 files changed

+93
-4
lines changed

Jest-Vue/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"axios": "^0.26.0",
2626
"core-js": "^3.19.3",
2727
"flush-promises": "^1.0.2",
28+
"joi": "^17.6.0",
2829
"nuxt": "^2.15.8",
2930
"view-design": "^4.7.0",
3031
"vue": "^2.6.14",

Jest-Vue/pages/index.vue

+52-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
<!--
2+
* @Author : your name
3+
* @Date : 2022-03-04 15:10:38
4+
* @LastEditTime : 2022-05-25 14:57:54
5+
* @FilePath : /Jest-Vue/pages/index.vue
6+
* @developer : yangfan36
7+
-->
18
<template>
29
<div class="container">
310
<div>
@@ -6,17 +13,58 @@
613
<h2 class="subtitle">Welcome to the View UI + Nuxt.js template</h2>
714
<br />
815
<SumTimerTool />
9-
<br />
16+
<br />
1017
<CustomParentComponent />
11-
<br />
12-
<FetchsBtnComponent />
18+
<br />
19+
<FetchsBtnComponent />
1320
</div>
1421
</div>
1522
</template>
1623

1724
<script>
25+
import Joi from 'joi'
1826
export default {
1927
name: 'IndexPage',
28+
created() {},
29+
async mounted() {
30+
const schema = Joi.object({
31+
username: Joi.string().alphanum().min(3).max(30).required(),
32+
33+
password: Joi.string().pattern(/^[a-zA-Z0-9]{3,30}$/),
34+
35+
repeat_password: Joi.ref('password'),
36+
37+
access_token: [Joi.string(), Joi.number()],
38+
39+
birth_year: Joi.number().integer().min(1900).max(2013),
40+
41+
email: Joi.string().email({
42+
minDomainSegments: 2,
43+
tlds: { allow: ['com', 'net'] },
44+
}),
45+
})
46+
.with('username', 'birth_year')
47+
.xor('password', 'access_token')
48+
.with('password', 'repeat_password')
49+
50+
schema.validate({ username: 'abc', birth_year: 1994 })
51+
// -> { value: { username: 'abc', birth_year: 1994 } }
52+
53+
// -> { value: {}, error: '"username" is required' }
54+
55+
// Also -
56+
57+
try {
58+
const value = await schema.validateAsync({
59+
username: 'abc',
60+
birth_year: 1994,
61+
})
62+
63+
console.log(value,'111')
64+
} catch (err) {
65+
console.log(err,'---')
66+
}
67+
},
2068
}
2169
</script>
2270

@@ -53,6 +101,6 @@ export default {
53101
}
54102

55103
p {
56-
margin: 20px 0;
104+
margin: 20px 0;
57105
}
58106
</style>

Jest-Vue/yarn.lock

+40
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,18 @@
11421142
resolved "https://pkgs.d.xiaomi.net:443/artifactory/api/npm/mi-npm/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"
11431143
integrity sha1-VVGTqy47s7atw9VRycAw2ehg2vY=
11441144

1145+
"@hapi/hoek@^9.0.0":
1146+
version "9.3.0"
1147+
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb"
1148+
integrity sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==
1149+
1150+
"@hapi/topo@^5.0.0":
1151+
version "5.1.0"
1152+
resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.1.0.tgz#dc448e332c6c6e37a4dc02fd84ba8d44b9afb012"
1153+
integrity sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==
1154+
dependencies:
1155+
"@hapi/hoek" "^9.0.0"
1156+
11451157
"@humanwhocodes/config-array@^0.9.2":
11461158
version "0.9.5"
11471159
resolved "https://pkgs.d.xiaomi.net:443/artifactory/api/npm/mi-npm/@humanwhocodes/config-array/-/config-array-0.9.5.tgz#2cbaf9a89460da24b5ca6531b8bbfc23e1df50c7"
@@ -1756,6 +1768,23 @@
17561768
resolved "https://pkgs.d.xiaomi.net:443/artifactory/api/npm/mi-npm/@polka/url/-/url-1.0.0-next.21.tgz#5de5a2385a35309427f6011992b544514d559aa1"
17571769
integrity sha1-XeWiOFo1MJQn9gEZkrVEUU1VmqE=
17581770

1771+
"@sideway/address@^4.1.3":
1772+
version "4.1.4"
1773+
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.4.tgz#03dccebc6ea47fdc226f7d3d1ad512955d4783f0"
1774+
integrity sha512-7vwq+rOHVWjyXxVlR76Agnvhy8I9rpzjosTESvmhNeXOXdZZB15Fl+TI9x1SiHZH5Jv2wTGduSxFDIaq0m3DUw==
1775+
dependencies:
1776+
"@hapi/hoek" "^9.0.0"
1777+
1778+
"@sideway/formula@^3.0.0":
1779+
version "3.0.0"
1780+
resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c"
1781+
integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==
1782+
1783+
"@sideway/pinpoint@^2.0.0":
1784+
version "2.0.0"
1785+
resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df"
1786+
integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==
1787+
17591788
"@sindresorhus/is@^0.14.0":
17601789
version "0.14.0"
17611790
resolved "https://pkgs.d.xiaomi.net:443/artifactory/api/npm/mi-npm/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
@@ -7073,6 +7102,17 @@ jju@^1.1.0:
70737102
resolved "https://pkgs.d.xiaomi.net:443/artifactory/api/npm/mi-npm/jju/-/jju-1.4.0.tgz#a3abe2718af241a2b2904f84a625970f389ae32a"
70747103
integrity sha1-o6vicYryQaKykE+EpiWXDzia4yo=
70757104

7105+
joi@^17.6.0:
7106+
version "17.6.0"
7107+
resolved "https://registry.yarnpkg.com/joi/-/joi-17.6.0.tgz#0bb54f2f006c09a96e75ce687957bd04290054b2"
7108+
integrity sha512-OX5dG6DTbcr/kbMFj0KGYxuew69HPcAE3K/sZpEV2nP6e/j/C0HV+HNiBPCASxdx5T7DMoa0s8UeHWMnb6n2zw==
7109+
dependencies:
7110+
"@hapi/hoek" "^9.0.0"
7111+
"@hapi/topo" "^5.0.0"
7112+
"@sideway/address" "^4.1.3"
7113+
"@sideway/formula" "^3.0.0"
7114+
"@sideway/pinpoint" "^2.0.0"
7115+
70767116
js-beautify@^1.6.12, js-beautify@^1.6.14:
70777117
version "1.14.0"
70787118
resolved "https://pkgs.d.xiaomi.net:443/artifactory/api/npm/mi-npm/js-beautify/-/js-beautify-1.14.0.tgz#2ce790c555d53ce1e3d7363227acf5dc69024c2d"

videos/chrome_mock_header.mp4

1.39 MB
Binary file not shown.

videos/chrome_mock_http.mp4

13 MB
Binary file not shown.

0 commit comments

Comments
 (0)