import { prefectures } from '../prefecture' ; import { genderList } from './gender' ; export const emailRules = [ ( v ) => ! ! v || 'E-mail is required' , ( v ) => /^\S+@\S+\.\S+$/ . test ( v ) || 'E-mail must be valid' , ] ; export const passwordRules = [ ( v ) => /.{6,}/ . test ( v ) || 'Password should be at least 6 characters' , ] ; export const genderRules = [ ( v ) => genderList . includes ( v ) || 'Gender is invalid' , ] ; export const prefectureRules = [ ( v ) => prefectures . includes ( v ) || 'Prefecture is invalid' , ] ; export const birthYearRules = [ ( v ) => ! ! v || 'Birth year is required' , ( v ) => /^(19|20)\d{2}$/ . test ( v ) || 'Birth year is invalid' , ] ; export const birthMonthRules = [ ( v ) => ! ! v || 'Birth month is required' , ( v ) => /^(1[0-2]|[1-9])$/ . test ( v ) || 'Birth month is invalid' , ] ; export const birthDayRules = [ ( v ) => ! ! v || 'Birth day is required' , ( v ) => /^([1-9]|[1-2][0-9]|3[0-1])$/ . test ( v ) || 'Birth day is invalid' , ] ; export const hireYearRules = [ ( v ) => ! ! v || 'Hire year is required' , ( v ) => /^(19|20)\d{2}$/ . test ( v ) || 'Hire year is invalid' , ] ; export const hireMonthRules = [ ( v ) => ! ! v || 'Hire month is required' , ( v ) => /^(1[0-2]|[1-9])$/ . test ( v ) || 'Hire month is invalid' , ] ; export const hireDayRules = [ ( v ) => ! ! v || 'Hire day is required' , ( v ) => /^([1-9]|[1-2][0-9]|3[0-1])$/ . test ( v ) || 'Hire day is invalid' , ] ; export const firstNameKanaRules = [ ( v ) => ! ! v || 'First name kana is required' , ( v ) => /^([ア-ン]|ー)+$/ . test ( v ) || 'Included not kana characters' , ] ; export const familyNameKanaRules = [ ( v ) => ! ! v || 'Family name kana is required' , ( v ) => /^([ア-ン]|ー)+$/ . test ( v ) || 'Included not kana characters' , ] ; const noSymbolRule = /^[^!"#$%&'()\*\+\-\.,\/:;<=>?@\[\\\]^_`{|}~]+$/ ; export const firstNameRules = [ ( v ) => ! ! v || 'First name is required' , ( v ) => noSymbolRule . test ( v ) || 'Symbol is included in first name' , ] ; export const familyNameRules = [ ( v ) => ! ! v || 'Family name is required' , ( v ) => noSymbolRule . test ( v ) || 'Symbol is included in family name' , ] ; export const displayNameRules = [ ( v ) => ! ! v || 'Display name is required' , ( v ) => /^[^!"#$%&'()\*\+\.,\/:;<=>?@\[\\\]^`{|}~]+$/ . test ( v ) || 'Display name is invalid' , ] ; export const urlRules = [ ( v ) => ! v || /^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/ . test ( v ) || 'Url is invalid' , ] ; export const postalCodeRules = [ ( v ) => ! v || /^\d{3}[-]\d{4}$|^\d{3}[-]\d{2}$|^\d{3}$|^\d{5}$|^\d{7}$/ . test ( v ) || 'Postal code is invalid' , ] ; export const requiredRules = ( message ) => [ ( v ) => ! ! v || message , ] ; export const numberRules = [ ( v ) => /^\d/ . test ( v ) || 'Accept number input only' , ( v ) => Number ( v ) > 0 || 'Required over 0' , ] ;