feat(client): add github to validation list (#40894)
This commit is contained in:
@ -39,7 +39,7 @@ function FormFields(props) {
|
||||
types = {}
|
||||
} = options;
|
||||
|
||||
const nullOrWarning = (value, error, isURL) => {
|
||||
const nullOrWarning = (value, error, isURL, name) => {
|
||||
let validationError;
|
||||
if (value && isURL) {
|
||||
try {
|
||||
@ -49,7 +49,7 @@ function FormFields(props) {
|
||||
}
|
||||
}
|
||||
const validationWarning = composeValidators(
|
||||
editorValidator,
|
||||
name === 'githubLink' ? null : editorValidator,
|
||||
localhostValidator
|
||||
)(value);
|
||||
const message = error || validationError || validationWarning;
|
||||
@ -90,7 +90,7 @@ function FormFields(props) {
|
||||
type={type}
|
||||
value={value}
|
||||
/>
|
||||
{nullOrWarning(value, !pristine && error, isURL)}
|
||||
{nullOrWarning(value, !pristine && error, isURL, name)}
|
||||
</FormGroup>
|
||||
</Col>
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Matches editor links for: Repl.it, Glitch, CodeSandbox
|
||||
const editorRegex = /repl\.it\/@|glitch\.com\/edit\/#!|codesandbox\.io\/s\//;
|
||||
// Matches editor links for: Repl.it, Glitch, CodeSandbox, GitHub
|
||||
const editorRegex = /repl\.it\/@|glitch\.com\/edit\/#!|codesandbox\.io\/s\/|github\.com/;
|
||||
const localhostRegex = /localhost:/;
|
||||
|
||||
export const editorValidator = value =>
|
||||
@ -11,4 +11,4 @@ export const localhostValidator = value =>
|
||||
: null;
|
||||
|
||||
export const composeValidators = (...validators) => value =>
|
||||
validators.reduce((error, validator) => error ?? validator(value), null);
|
||||
validators.reduce((error, validator) => error ?? validator?.(value), null);
|
||||
|
@ -20,7 +20,7 @@ export function formatUrlValues(values, options) {
|
||||
let value = values[key];
|
||||
const nullOrWarning = composeValidators(
|
||||
localhostValidator,
|
||||
editorValidator
|
||||
key === 'githubLink' ? null : editorValidator
|
||||
)(value);
|
||||
if (nullOrWarning) {
|
||||
validatedValues.invalidValues.push(nullOrWarning);
|
||||
|
Reference in New Issue
Block a user