File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 <div class =" input-group" >
66 <div class =" label-group" >
77 <label class =" project-name-label" for =" project-name" >Project Name</label >
8- <div class =" project-name-length-indicator" >{{ localProjectName.length }} / 50</div >
98 </div >
109 <div class =" input-horizontal" >
1110 <input
1918 :value =" localProjectName"
2019 @input =" handleInputChange($event)"
2120 :disabled =" projectStore.isProjectNameConfirmed"
22- maxlength =" 50 "
21+ maxlength =" 100 "
2322 />
2423 <button
2524 class =" confirm-btn"
4039<script setup>
4140import { ref , onMounted } from " vue"
4241import { useProjectStore } from " @/stores/useProjectStore"
42+ import { isValidProjectName } from " @/utils/validation"
4343
4444const projectStore = useProjectStore ()
4545const localProjectName = ref (" asd" )
4646const showError = ref (false )
4747const errorMessage = ref (" " )
4848
49- const isValidProjectName = (name ) => {
50- return / ^ [a-zA-Z _][a-zA-Z0-9 _-] * $ / .test (name)
51- }
52-
5349const handleInputChange = (event ) => {
5450 localProjectName .value = event .target .value
5551
Original file line number Diff line number Diff line change 1+ export const patterns = {
2+ boundedStr : / ^ .{ 1 , 100 } $ / ,
3+ snakeCase : / ^ [ a - z ] [ a - z 0 - 9 _ ] * $ / ,
4+ enumStr : / ^ [ a - z A - Z ] [ a - z A - Z 0 - 9 _ ] * $ / ,
5+ projectName : / ^ [ a - z A - Z _ ] [ a - z A - Z 0 - 9 _ - ] * $ / ,
6+ }
7+
8+ export const isValidProjectName = ( value : string ) : boolean => {
9+ return patterns . boundedStr . test ( value ) && patterns . projectName . test ( value )
10+ }
You can’t perform that action at this time.
0 commit comments