//TODO implement & export

function validateRequired(value) {
	return value || value === 0 || value === false;
}


function validateNumber(num, i18n) {
	if (!num) {
		return true;
	}
	//TODO try to convert value
	return !isNaN(num);
}


function validateDecimal(num, i18n) {
	if (!num) {
		return true;
	}
	//TODO try to convert value
	return !isNaN(num);
}


const emailRegexp = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;

function validateEmail(email) {
	return !email || emailRegexp.test(email);
}


export default {
	required: validateRequired,
	number: validateNumber,
	decimal: validateDecimal,
	email: validateEmail
}
