MCPcopy
hub / github.com/directus/directus / validateEmail

Method validateEmail

api/src/services/users.ts:172–188  ·  view source on GitHub ↗

* Validate array of emails. Intended to be used with create/update users

(input: string | string[])

Source from the content-addressed store, hash-verified

170 * Validate array of emails. Intended to be used with create/update users
171 */
172 private validateEmail(input: string | string[]) {
173 const emails = Array.isArray(input) ? input : [input];
174
175 const schema = Joi.string().email().required();
176
177 for (const email of emails) {
178 const { error } = schema.validate(email);
179
180 if (error) {
181 throw new FailedValidationError({
182 field: 'email',
183 type: 'email',
184 path: [],
185 });
186 }
187 }
188 }
189
190 /**
191 * Block setting a non-default auth provider when the current license isn't entitled to SSO

Callers 3

createOneMethod · 0.95
createManyMethod · 0.95
updateManyMethod · 0.95

Calls 1

stringMethod · 0.80

Tested by

no test coverage detected