Publish validation fix
This commit is contained in:
parent
46953da4cc
commit
cfa9371851
3 changed files with 62 additions and 41 deletions
|
|
@ -19,6 +19,7 @@ interface State {
|
|||
validateMain: boolean;
|
||||
validateMainCallback: any;
|
||||
onMainReady: any;
|
||||
mainRules: any;
|
||||
}
|
||||
|
||||
const defaultState: State = {
|
||||
|
|
@ -63,7 +64,20 @@ const defaultState: State = {
|
|||
debug: false,
|
||||
validateMain: false,
|
||||
onMainReady: () => false,
|
||||
validateMainCallback: (d = false) => d
|
||||
validateMainCallback: (d = false) => d,
|
||||
mainRules: {
|
||||
name: [
|
||||
(v: any) => v.length >= 3 || 'Au minimum 3 caractères',
|
||||
(v: any) => v.length <= 50 || 'Au maximum 50 caractères'
|
||||
],
|
||||
descriptionShort: [
|
||||
(v: any) => v.length >= 20 || 'Au minimum 20 caractères',
|
||||
(v: any) => v.length <= 200 || 'Au maximum 200 caractères'
|
||||
],
|
||||
tags: [(v: any) => (Array.isArray(v) && v.length > 0) || 'Vous devez choisir au minimum une catégorie'],
|
||||
'contacts.email': [(v: any) => /.+@.+\..+/.test(v) || "L'email est requis et doit être valide"],
|
||||
'contacts.person': [(v: any) => v.length >= 4 || 'Au minimum 4 caractères']
|
||||
}
|
||||
}
|
||||
|
||||
export default new Vuex.Store({
|
||||
|
|
@ -99,6 +113,11 @@ export default new Vuex.Store({
|
|||
},
|
||||
VALIDATE_MAIN (state: State, callback) {
|
||||
state.validateMain = true
|
||||
if (callback === undefined) {
|
||||
callback = (d: boolean) => {
|
||||
return true
|
||||
}
|
||||
}
|
||||
state.validateMainCallback = (d: boolean) => {
|
||||
state.validateMain = false
|
||||
return callback(d)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue