export const required_data = {
	required: true,
	message: '必须输入',
	trigger: 'blur'
}

export const number_data = (n = 2) => {
	return {
		pattern: /^-?\d+(\.\d{1, n})?$/,
		message: `请输入正确的数字,最多 ${n} 位小数`,
		trigger: 'blur'
	}
}

export const positive_integer_data = {
	pattern: /^[0-9]\d*$/,
	message: `请输入正整数`,
	trigger: 'blur'
}

export const required_array = {
	required: true,
	transform: (arr) => {
		if (arr) return arr.join('')
		return arr
	},
	message: '必须项',
	trigger: 'blur'
}

export const default_number_data = number_data(2)

export const just_required = [required_data]

export const number_required = (n = 2) => [number_data(n), required_data]

export const default_number_required = [default_number_data, required_data]

export const positive_integer_required = [positive_integer_data, required_data]
