ããã«ã¡ã¯ãLayerX ãã¯ã©ã¯äºæ¥é¨ ãã¯ã©ã¯è«æ±æ¸ååã»ä»è¨³ãã¼ã ã¨ã³ã¸ãã¢ã® coco ã§ããæè¿äººçã§åãã¦ã¯ãªã¹ãã¹ã«ãã¬ã¼ã³ããããã¨ãããã¨ããã¾ãããåãã§ããããã¨å¬ãããã®ã§ããã
ãã®è¨äºã¯ LayerXããã¯ã¢ãã«ã¬2023 47æ¥ç®ã®è¨äºã§ãã ååã¯åãã ãã¯ã©ã¯è«æ±æ¸ååã»ä»è¨³ãã¼ã ã® noritama ããã ãBurpSuiteã使ã£ã¦ãµã¯ã£ã¨Webã¢ããªã±ã¼ã·ã§ã³ã®èå¼±æ§è¨ºæãå®æ½ããããæ¸ãã¦ãã ããã¾ããã 次åãåãã¼ã ã® wataru ãããæ¸ãã¦ãããäºå®ãªã®ã§ãæå¾ ãã ããï¼
ä»å㯠ãã¯ã©ã¯è«æ±æ¸ååã»ä»è¨³ãã¼ã ã§è¡ã£ã Vue3 移è¡ä½æ¥ã®ãã¡ã® VeeValidate v4 ã®ç ´å£çå¤æ´ãäºæã³ã³ãã¼ãã³ããç¨æãã¦ä¹ãåã£ãæ¹æ³ã«ã¤ãã¦ãç´¹ä»ãã¾ããå ¨ä½çãªç¶æ ã¨é²è¡ã¯ä¸»ã« tatane ããã® ããã¯ã©ã¯ã® Vue3 移è¡æ¦ç¥ã¨è©°ã¾ã£ããã¤ã³ãã ãåèã«ãã¦ããã ããã°ã¨æãã¾ãã
Vue3 åã®å¯¾å¿æ¹é
Vue3 åã®ä½æ¥ã¯2023å¹´ã®7æããã¹ã¿ã¼ããã¾ããã
Vue2 ã® EOL(end of life) ã¯2023å¹´ã®æ«ã¨åå¹´ã»ã©æ®ã£ã¦ããç¶æ ã§ãããããã¯ã©ã¯è«æ±æ¸ååã»ä»è¨³ ã¯ãã¯ã©ã¯ã·ãªã¼ãºã®ä¸ã§ãæãæ´å²ãé·ããã¨ããããNuxt ã使ç¨ãã¦ããã©ã¤ãã©ãªã®ãã¼ã¸ã§ã³ãæãå¤ããä¸ç¢ºå®æ§ãé«ããã¨ããæéã§éå§ã§ãããã®ææã«éå§ãã¾ããã
å½æãã¯ã©ã¯è«æ±æ¸ååã»ä»è¨³ ã§ã¯ã¤ã³ãã¤ã¹å¶åº¦å¯¾å¿ã®æ©è½ã次ã ã¨ãªãªã¼ã¹ããã主ã«ãã¡ãã«ãã¼ã ã®ãªã½ã¼ã¹ãå²ãã¦ããããæ°æ©è½éçºãæ¢ã㦠Vue3 åã«æ³¨åããã¨ããé¸æè¢ã¯åããªãç¶æ ã§ãããã¾ãQAãã¼ã ã®ãªã½ã¼ã¹ãéããã¦ããããæ éã«æ¤è¨¼ãããªãã¹ãå½±é¿ç¯å²ãå°ãããªãããã«ãªãªã¼ã¹ãéãã¦ããã¾ããã
VeeValidate v4ã®ç ´å£çå¤æ´
VeeValidate 㯠vue ã® form validation ç¨ã®ã©ã¤ãã©ãªã§ããVeeValidate 㯠Vue3 åã«ä¼´ã£ã¦ v3 ãã v4 ã«ã¢ãããã¼ãããå¿ è¦ããããVeeValidate ã® v3 㨠v4 ã® IF ã¨æ©è½ã®éã ã®éããã ãã¯ã©ã¯è«æ±æ¸ååã»ä»è¨³ ã§å¤ãã®ç ´å£çå¤æ´ãå¿ è¦ã§ããã
å ·ä½çã«ã¯æ©è½ã®éãã«ãã£ã¦å ¨ã¦ã® VeeValidate ã®ä½¿ç¨ç®æã®ãã¸ãã¯ã®å¤æ´ãããã« IF ã®éãããã³ã¼ãã®å¤æ´ç®æãå¤ããªãã¾ãã
ãã¯ã©ã¯è«æ±æ¸ååã»ä»è¨³ ã§ã¯ã»ã¼å ¨ã¦ã®ãã©ã¼ã 㧠VeeValidate ã使ç¨ãã¦ããã以ä¸ã®ç¹ã§å ¨ã¦ã®ãã©ã¼ã ã«ç ´å£çå¤æ´ãå ããã®ã¯ç¾å®çã§ã¯ãªãã¨ããå¤æã«ãªãã¾ããã
- ãã©ã¼ã æ°ãå¤ããå ¨ç®æãå¤æ´ããå ´åã®æ¤è¨¼ã«è¦ããQAå·¥æ°ã確ä¿ã§ããªã
- ã¦ã¼ã¶ã¼å½±é¿ããã£ãå ´åã®æ·±å»åº¦ã大ããä»è¨³ç»é¢ã§ä½¿ç¨ããã¦ãã
Vue2, Vue3 ã§ç ´å£çå¤æ´ããªã validation ã©ã¤ãã©ãªãããã°ãã¡ãã¸ã®ç§»è¡ãæ¤è¨ãããã£ãã®ã§ããããããã£ãã©ã¤ãã©ãªã¯è¦ã¤ããã¾ããã§ããã
ãããã VeeValidate ã v3 ã§å®è£ ãã¦ãã IFãç¶æã§ããã«ç ´å£çãªå¤æ´ãããããå¾ãªãã£ãçç±ã調æ»ããã¨ãã Vue å é¨ã® VNode ã® API ã大ããå¤ãã£ããã¨ã«ãã£ã¦ v-model ãé©ç¨ããã¦ããå ´æãæ¤ç¥ã§ããªããªã£ã¦ãããã¨ã主ãªåå ã ã¨ãããã¨ããããã¾ããã
v-model ãé©ç¨ããã¦ããå ´æãæ¤ç¥ãã¦ãã¦ã¼ã¶ã¼ã®å ¥åã«ãã inputã¤ãã³ãçãããªã¬ã¼ã«validationãå®è¡ãã¦ãããããvalidationã®å®è¡ã¿ã¤ãã³ã°ãæ´ããªããªã£ã¦ããããã§ãã
ããã VeeValidate v3 ã®ã½ã¼ã¹ã³ã¼ããèªãã ã¨ãã以ä¸ã®ç¹ãã validation ã®å®è¡ã¿ã¤ãã³ã°ãèªåã§ç¨æãããã¨ã§ VeeValidate v3 ã®ä½¿ç¨ç®æãé¨åçã«ç§»è¡ãã¦ãããã¨ãã§ããã®ã§ã¯ãªããã¨èãã¾ããã
- validation ç¨ã®é¢æ°ã¯åãåºããã¦ãããvue ã® reactive system ã«ä¾åãã¦ããªã â 好ããªå ´æãã好ããªã¿ã¤ãã³ã°ã§ validation ãã¸ãã¯ãå®è¡ã§ãã
- ValidationObserver 㨠ValidationProvider ã®é£æºãVeeValidateãèå¥ããæååã provide/inject ãããã¨ã§è¡ããã¦ãã â åãæååã provide/inject ãããã¨ã§ VeeValidate ã¨é£æºãããã¨ãã§ãã
VeeValidate äºæã³ã³ãã¼ãã³ã
åæã¨ã㦠ãã¯ã©ã¯è«æ±æ¸ååã»ä»è¨³ ã®ã¦ã¼ã¹ã±ã¼ã¹ã«ããã¦äºææ§ãæããã¦ããã®ã§VeeValidateã®å ¨ã¦ã®æ©è½ã§äºææ§ãããããã§ã¯ãªãã§ãã
validation å®è¡ã¿ã¤ãã³ã°
ã¦ã¼ã¶ã¼ãå ¥åãè¡ã£ãã¿ã¤ãã³ã°ã§ validation ã®å®è¡ãè¡ãããã®ã§ form ã« bind ãã¦ããå¤ãwatchãã¦ãå¤åãèµ·ãã£ãã¿ã¤ãã³ã°ã§ validation ãå®è¡ãããã¨ã«ãã¾ããã
注æããç¹ã¨ãã¦ã¯ inputã¤ãã³ãçã®å ¥åãæ¤ç¥ãã¦ããããã§ã¯ãªããreactive ãªå¤ã®å¤æ´ãæ¤ç¥ãã¦ãããããè£å®æ©è½çã«ãã£ã¦å¤ãä¸æ¸ããããã¿ã¤ãã³ã°ã§ã validation ãå®è¡ããã¦ãã¾ãã¾ãã
ãã¯ã©ã¯è«æ±æ¸ååã»ä»è¨³ã§ã¯è£å®ããã¿ã¤ãã³ã°ã§ validation ã®å®è¡çµæããªã»ãããããããªä»æ§ã«ãªã£ã¦ããã®ã§å®è¡çµæãresetããé¢æ°ãæä¾ããè£å®å¾ã«ãããå¼ã³åºãå½¢ã§å¯¾å¿ãã¾ããã
export const useLxValidationProvider = <T extends string | number | boolean | string[] | number[] | null>( value: ComputedRef<T>, ... ): LxProvider => { ... const reset = async () => { // validation ç¶æ ã® reset } const lxProvider: LxProvider = { ... reset, } // valueã®å¤æ´ãç£è¦ããvalidationãå®è¡ãã watch(value, () => validate()) return lxProvider }
VeeValidate ã¨ã®é£æº
åè¿°ããéã VeeValidate ã ValidationObserver, ValidationProvider ã®é£æºã«ä½¿ç¨ãã¦ã provide/inject ç¨ã®æååã使ç¨ãã¦ãªãªã¸ãã«ã®ã³ã³ãã¼ãã³ãï¼LxValidationObserver, LxValidationProviderï¼ã®é£æºãè¡ã£ã¦ããã¾ãã
provide/inject ã§ä½¿ç¨ããã¦ããæååã¯éå ¬éã®å é¨ã§ä½¿ç¨ããã¦ãããã®ã§ãããVeeValidate v3 ã¯2022å¹´ã®7æããæ´æ°ããã¦ããããä»å¾ãæ´æ°ããããªãå¯è½æ§ãé«ããã¨ãã使ç¨ãã¦ãåé¡ãªãã¨å¤æãã¾ããã
export const useLxValidationObserver = (): LxObserver => { ... // VeeValidate ã® Provider ãæ¾ããããã« VeeValidate ã® InjectionKey ã使ç¨ãã const providedVee = inject<VeeLikeObserver | null>(VeeValidateInjectionKey, null) if (!providedVee) { provide<VeeLikeObserver>(VeeValidateInjectionKey, veeLikeObserver) } } export const useLxValidationProvider = (...): LxProvider => { ... // Subscribe å¦ç const $veeObserver = inject<VeeLikeObserver | null>(LxValidateInjectionKey, null) if ($veeObserver) { $veeObserver.observe(lxProvider, LxObserverSubscriberType.LxProvider) onBeforeUnmount(() => { $veeObserver.unobserve(lxProvider.id, LxObserverSubscriberType.LxProvider) }) } }
ãã㧠VeeValidate ã¨é£æºãããã¨ãã§ããããã«ãªã£ãã®ã§å½±é¿ç¯å²ãå°ããããããã«æ®µéçã«ç§»è¡ãããã¨ãå¯è½ã«ãªãã¾ãã
ç½®ãæããè¡ãé çªã¨ãã¦ä»¥ä¸ã®äºã¤ãèãããã¾ã
- ValidationObserver ã LxValidationObserver ã«ç½®ãæããã®ã¡ã« ValidationProvider ã LxValidationProvider ã«ç½®ãæãã
- ValidationProvider ã LxValidationProvider ã«ç½®ãæããã®ã¡ã« ValidationObserver ã LxValidationObserver ã«ç½®ãæãã
ValidationProvider ããç½®ãæãã¦ãã¾ã£ãå ´å ValidationObserver ã ValidationProvider ã«æå¾ ãã¦ããå ¨ã¦ã®æ¯ãèãã«å¯¾å¿ãããå¿ è¦ãåºã¦ãã¾ãã
å ¨ã¦ã®æ©è½ã«äºææ§ãæããããããã§ã¯ãªãããã¯ã©ã¯è«æ±æ¸ååã»ä»è¨³ ã«ãããã¦ã¼ã¹ã±ã¼ã¹ã§äºææ§ãæãããã®ã§ååã§ãã£ããããå¾è ã®æ¹æ³ã§ç½®ãæãããã¨ã§æä½éã®æ©è½ã®ç½®ãæãã§æ¸ã¾ãã¾ããã
äºææ§ã®å¯¾å¿è¡¨ã¯ä»¥ä¸ã®ããã«ãªã£ã¦ã¾ãã
ãã®è¡¨ããåããããã« ValidationObserver ãä¸æ¬ã㦠LxValidationObserver ã«å¤æ´ããå¾ã«æ®µéçã« ValidationProvider ã LxValidationProvider ã«å¤æ´ãããã¨ãã§ãã¾ãã
ValidationObserver ãä¸æ¬ãã¦å¤æ´ããããå½±é¿ç¯å²ã¯å¤§ãããªãã¾ãããObserver ã主ã«æä¾ãã¦ããæ©è½ã¯ãã¹ããã¦ãã Provider ã® status ã®éç´ã¨ reset æ©è½ã®æä¾ã§ãããããã®æ©è½ã«é¢ã㦠VeeVlidate ãè¡ã£ã¦ãããã¹ãã®å 容ã¨åããã®ããªãªã¸ãã«ã®ã³ã³ãã¼ãã³ãã§ãç¨æãããã¨ã§ QA ãå ¨ã¦ã®ãã©ã¼ã ãäºç´°ãã«æ¤è¨¼ããã¨ããform ã® status ã UI ã«è¡¨ç¤ºããã¦ãããã¨ã確èªããã ãã§æ¸ãããã«ãã¾ããã
ValidationObserver ã®ç½®ãæããå®äºããã°ããã¨ã¯ ValidationProvider â LxValidationProvider ã段éçã«ç§»è¡ãããã¨ãã§ããã®ã§å½±é¿ç¯å²ãå°ããããªãªã¼ã¹ãåå²ãã¦è¡ãã¾ãã
çµæ
çµæã¨ãã¦ãªãªã¸ãã«ã®ã³ã³ãã¼ãã³ããå©ç¨ãããã¨ã§å½±é¿ç¯å²ãå°ããã§ããã¤ã³ã·ãã³ãã hotfix ã«ã¤ãªãããã¨ãªãå®å ¨ã«ç§»è¡ãããã¨ãã§ãã¾ããã ç¾å¨ããããã¯ã·ã§ã³ã§å æ°ã«åãã¦ããã¦ãã¾ãã
ã¤ã³ã·ãã³ãã®çºçãä¸çªã®èª²é¡ã¨æãã¦ããã®ã§å¬ããéãã§ãã
ã¾ããå®è£ 詳細ã«ã¤ãã¦è§¦ãããã¨ã¯ã§ãã¾ããã§ããããã³ã³ãã¼ãã³ãã® IF ã VeeValidate ã¨ã»ã¼åãå½¢ã«ããã¨ãããã¨ããã¦ãã¾ããã ãã®çµæãã³ã¼ãã®å¤æ´ç®æãå°ãªããªããã¬ãã¥ã¼ãããããããã¹ãèµ·ããã¥ããã£ãããã«æãã¾ãã
ããã«ãã¼ã å ã§ä½æ¥ãåæ ãããã¨ã§ã¤ã³ãã¤ã¹å¶åº¦ã®æ°æ©è½ã«ã対å¿ããªãã2åã®ãªãªã¼ã¹ï¼ç´1ã¶æï¼ã§ç§»è¡ãå®äºããããã¨ãã§ãã¾ããã
æ¯è¿ã
ç ´å£çå¤æ´ã«ãããå½±é¿ç¯å²ãå°ããããããã«ãªãªã¸ãã«ã®ã³ã³ãã¼ãã³ããä½æã対å¿ããã¨ãããã¨ããã¾ãããçµæã§ãæ¯ãè¿ã£ãããã«ã¤ã³ã·ãã³ãã«ãªããã«çæéã§ç½®ãæãããã¨ãã§ãã¾ããã
ã§ããããªãªã¸ãã«ã³ã³ãã¼ãã³ãã®éçºããã¹ãå®è£ ãåä½ç¢ºèªãã¡ã³ãã¼å ±æã®ããã®ããã¥ã¡ã³ãä½æãªã©æ³å以ä¸ã«ãããã¨ãå¤ãã£ãããæ£ç´ããããããã¯ãªãã§ãããããw
ä»å¾ã¨ãã¦ã¯ãUXã®åä¸ãã¡ã³ããã³ã¹ã³ã¹ãã®è¦³ç¹ã§ãªãªã¸ãã«ã®ã³ã³ãã¼ãã³ããå¥ã®ã©ã¤ãã©ãªã«ç½®ãæãã対å¿ãå¿ è¦ã«ãªããã¨æãã¾ãããã¡ãã«é¢ãã¦ã¯ç§»è¡å ã®ã©ã¤ãã©ãªã¨å ±åããã¤ã¤ãã©ã¼ã æ¯ã«æ®µéçã«ç§»è¡ããããã¨æãã®ã§ææãè¦ã¦ãã£ã¦ããããã¨æãã¾ãã
ãããã«
ä»å㯠ãã¯ã©ã¯è«æ±æ¸ååã»ä»è¨³ ã§è¡ã£ã VeeValidate ã®ç§»è¡ã«ã¤ãã¦ãç´¹ä»ããã¦ããã ãã¾ããã
Vue3åã ãã«çã¾ããä¿å®æ§ãããã©ã¼ãã³ã¹ã®è¦³ç¹ã§ã®æ¹åãªã©èª²é¡ã¯å±±ç©ã¿ã§ãããã
ãã¯ã©ã¯äºæ¥é¨ã§ã¯ããã³ãã¨ã³ãã®ã«ã¤ã¼ã³ãããã¾ã§ä»¥ä¸ã«é²ãã¦ãããã¨æã£ã¦ããããããã¯ãã¨ã³ã¸ãã¢ã«å ãã¦ãããã³ãã¨ã³ãEnablingãã¨ãã£ããã¼ã«ã®æ¡ç¨ãå§ãã¦ãã¾ãã
ãã¿ã©ã¯ããã¯ã©ã¯ã«ãããããã¯ããä¸ç·ã«éçºãã¦ãããã人ãã¹ãã·ã£ãªã¹ãã¨ãã¦äºæ¥é¨å ¨ä½ã®ããã³ãã¨ã³ããã«ã¤ã¼ã³ãã¦ãããã人ã大åéä¸ã§ãï¼ãããèå³ããã¾ãããããã²ã«ã¸ã¥ã¢ã«é¢è«ããã話ããã¦ãã ããï¼