Commit 165ee20b authored by aleclofabbro's avatar aleclofabbro

Merge branch 'fix/loose_email_and_domain_regex_validations' into develop

parents 0efde2a6 dc9cc58a
......@@ -7,6 +7,7 @@ import { ShareLink } from 'ui/modules/ShareLink';
import { ShareResource } from 'ui/modules/ShareLink/fetched';
import * as Yup from 'yup';
import { i18n } from 'context/global/localizationCtx';
import { DOMAIN_REGEX } from 'mn-constants';
export const validationSchema = Yup.object<ShareResource>({
name: Yup.string()
......@@ -39,7 +40,9 @@ export const ShareLinkHOC: FC<ShareLinkHOC> = ({
const { current: urlValidationSchema } = useRef(
Yup.object<{ fetchUrl: string }>({
fetchUrl: Yup.string().required(i18n._('url is required'))
fetchUrl: Yup.string()
.matches(DOMAIN_REGEX)
.required(i18n._('url is required'))
})
);
......
......@@ -4,11 +4,10 @@ import { useInstanceRegistrationAllowLists } from 'fe/settings/instance/registra
import { useFormik } from 'formik';
import * as Yup from 'yup';
import { useFormikPage } from 'fe/lib/helpers/usePage';
import { DOMAIN_REGEX } from 'mn-constants';
export const withEmailDomainValidation = Yup.object().shape({
domain: Yup.string().matches(
/^(?!:\/\/)([a-zA-Z0-9-_]+\.)*[a-zA-Z0-9][a-zA-Z0-9-_]+\.[a-zA-Z]{2,11}?$/gim
)
domain: Yup.string().matches(DOMAIN_REGEX)
});
export interface InstanceSettingsSection {}
......
......@@ -4,11 +4,12 @@ import { useInstanceRegistrationAllowLists } from 'fe/settings/instance/registra
import { useFormik } from 'formik';
import * as Yup from 'yup';
import { useFormikPage } from 'fe/lib/helpers/usePage';
import { EMAIL_REGEX } from 'mn-constants';
export interface InstanceInvitesSection {}
export const withEmailValidation = Yup.object().shape({
email: Yup.string().email()
email: Yup.string().matches(EMAIL_REGEX)
});
export const InstanceInvitesSection: FC<InstanceInvitesSection> = () => {
......
......@@ -3,9 +3,10 @@ import Preferences, { EditPreferences } from 'ui/pages/settings/preferences';
import { useFormik } from 'formik';
import { useProfile } from 'fe/user/profile/useProfile';
import * as Yup from 'yup';
import { DOMAIN_REGEX } from 'mn-constants';
const validationSchema = Yup.object<EditPreferences>({
moodleWebsite: Yup.string().url()
moodleWebsite: Yup.string().matches(DOMAIN_REGEX)
});
export const PreferencesSettingsSection: FC = () => {
......
......@@ -6,6 +6,7 @@ import {
} from 'ui/modules/MoodlePanel';
import * as Yup from 'yup';
import Maybe from 'graphql/tsutils/Maybe';
import { DOMAIN_REGEX } from 'mn-constants';
export interface LMSPrefsPanel {
done(): unknown;
......@@ -17,7 +18,7 @@ export interface LMSPrefsPanel {
}
const validationSchema = Yup.object<BasicMoodleLMSConfigFormValues>({
site: Yup.string()
.url()
.matches(DOMAIN_REGEX)
.required()
});
export const LMSPrefsPanel: FC<LMSPrefsPanel> = ({
......
{"__schema":{"types":[{"kind":"UNION","name":"ActivityContext","possibleTypes":[{"name":"Collection"},{"name":"Comment"},{"name":"Community"},{"name":"Flag"},{"name":"Follow"},{"name":"Like"},{"name":"Resource"},{"name":"User"}]},{"kind":"UNION","name":"FeatureContext","possibleTypes":[{"name":"Collection"},{"name":"Community"}]},{"kind":"UNION","name":"LikeContext","possibleTypes":[{"name":"Collection"},{"name":"Comment"},{"name":"Community"},{"name":"Resource"},{"name":"User"}]},{"kind":"UNION","name":"DeleteContext","possibleTypes":[{"name":"Collection"},{"name":"Comment"},{"name":"Community"},{"name":"Feature"},{"name":"Flag"},{"name":"Follow"},{"name":"Like"},{"name":"Resource"},{"name":"Thread"},{"name":"User"}]},{"kind":"UNION","name":"FollowContext","possibleTypes":[{"name":"Collection"},{"name":"Community"},{"name":"Thread"},{"name":"User"}]},{"kind":"UNION","name":"ThreadContext","possibleTypes":[{"name":"Collection"},{"name":"Community"},{"name":"Flag"},{"name":"Resource"}]},{"kind":"UNION","name":"FlagContext","possibleTypes":[{"name":"Collection"},{"name":"Comment"},{"name":"Community"},{"name":"Resource"},{"name":"User"}]}]}}
\ No newline at end of file
{"__schema":{"types":[{"kind":"UNION","name":"ActivityContext","possibleTypes":[{"name":"Collection"},{"name":"Comment"},{"name":"Community"},{"name":"Flag"},{"name":"Follow"},{"name":"Like"},{"name":"Resource"},{"name":"User"}]},{"kind":"UNION","name":"FollowContext","possibleTypes":[{"name":"Collection"},{"name":"Community"},{"name":"Thread"},{"name":"User"}]},{"kind":"UNION","name":"FlagContext","possibleTypes":[{"name":"Collection"},{"name":"Comment"},{"name":"Community"},{"name":"Resource"},{"name":"User"}]},{"kind":"UNION","name":"FeatureContext","possibleTypes":[{"name":"Collection"},{"name":"Community"}]},{"kind":"UNION","name":"DeleteContext","possibleTypes":[{"name":"Collection"},{"name":"Comment"},{"name":"Community"},{"name":"Feature"},{"name":"Flag"},{"name":"Follow"},{"name":"Like"},{"name":"Resource"},{"name":"Thread"},{"name":"User"}]},{"kind":"UNION","name":"ThreadContext","possibleTypes":[{"name":"Collection"},{"name":"Community"},{"name":"Flag"},{"name":"Resource"}]},{"kind":"UNION","name":"LikeContext","possibleTypes":[{"name":"Collection"},{"name":"Comment"},{"name":"Community"},{"name":"Resource"},{"name":"User"}]}]}}
\ No newline at end of file
......@@ -87,10 +87,8 @@ export const mothershipCreds =
export const searchDisabled = !mothershipCreds;
export const USERNAME_REGEX = /^[a-zA-Z][a-zA-Z0-9-]{2,}$/;
export const max_file_size = '10MB';
export const accepted_file_types =
'.pdf, .rtf, .docx, .doc, .odt, .ott, .xls, .xlsx, .ods, .ots, .csv, .ppt, .pps, .pptx, .odp, .otp, .odg, .otg, .odc, .ogg, .mp3, .flac, .m4a, .wav, .mp4, .mkv, .flv, .avi, .gif, .jpg, .jpeg, .png, .svg, .webm, .eps, .tex, .mbz';
export const EMAIL_REGEX = /^.+@.+\..+$/;
export const DOMAIN_REGEX = /^.+\..+$/;
// these licenses must match the icons (in the same order) configured in the UploadResource UI module
// please use standard identifiers from https://spdx.org/licenses/preview/ in order to preserve interoperability
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment