import React from 'react';
import { Trans } from 'react-i18next';
// Matches editor links for: Repl.it, Glitch, CodeSandbox, GitHub
const editorRegex = /repl\.it\/(@|join\/)|glitch\.com\/edit\/#!|codesandbox\.io\/s\/|github\.com/;
const fCCRegex = /codepen\.io\/freecodecamp|freecodecamp\.rocks|github\.com\/freecodecamp/i;
const localhostRegex = /localhost:/;
export const editorValidator = value =>
editorRegex.test(value) ? validation.editor-url : null;
export const fCCValidator = value =>
fCCRegex.test(value) ? validation.own-work-url : null;
export const localhostValidator = value =>
localhostRegex.test(value) ? (
validation.publicly-visible-url
) : null;
export const composeValidators = (...validators) => value =>
validators.reduce((error, validator) => error ?? validator?.(value), null);