mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-06 06:17:11 -04:00
🔧:build SSR dist and deploy
This commit is contained in:
parent
76c26901d7
commit
c59ad6aedb
465 changed files with 214127 additions and 2 deletions
50
dist/server/chunks/chunk-35c3d701.js
vendored
Normal file
50
dist/server/chunks/chunk-35c3d701.js
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
import { get } from '@vueuse/core';
|
||||
import _ from 'lodash';
|
||||
import { reactive, watch } from 'vue';
|
||||
|
||||
function isFalsyOrHasThrown(cb) {
|
||||
try {
|
||||
const returnValue = cb();
|
||||
if (_.isNil(returnValue)) {
|
||||
return true;
|
||||
}
|
||||
return returnValue === false;
|
||||
} catch (_2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function useValidation({
|
||||
source,
|
||||
rules,
|
||||
watch: watchRefs = []
|
||||
}) {
|
||||
const state = reactive({
|
||||
message: "",
|
||||
status: void 0,
|
||||
isValid: false,
|
||||
attrs: {
|
||||
validationStatus: void 0,
|
||||
feedback: ""
|
||||
}
|
||||
});
|
||||
watch(
|
||||
[source, ...watchRefs],
|
||||
() => {
|
||||
state.message = "";
|
||||
state.status = void 0;
|
||||
for (const rule of get(rules)) {
|
||||
if (isFalsyOrHasThrown(() => rule.validator(source.value))) {
|
||||
state.message = rule.message;
|
||||
state.status = "error";
|
||||
}
|
||||
}
|
||||
state.isValid = state.status !== "error";
|
||||
state.attrs.feedback = state.message;
|
||||
state.attrs.validationStatus = state.status;
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
return state;
|
||||
}
|
||||
|
||||
export { useValidation as u };
|
Loading…
Add table
Add a link
Reference in a new issue