mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 10:19:20 +03:00
24 lines
830 B
TypeScript
24 lines
830 B
TypeScript
import { schema, rules } from '@ioc:Adonis/Core/Validator';
|
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
|
|
|
export default class UpdateContactsValidator {
|
|
constructor(protected ctx: HttpContextContract) {}
|
|
|
|
public schema = schema.create({
|
|
phone_number: schema.string.optional({}, [
|
|
rules.mobile({
|
|
locales: ['ru-RU', 'en-US'],
|
|
strict: true,
|
|
}),
|
|
rules.unique({ table: 'contacts', column: 'phone_number' }),
|
|
]),
|
|
vk_id: schema.string.optional({}, [rules.regex(/^([a-zA-Z0-9_]){1,64}$/)]),
|
|
twitter_id: schema.string.optional({}, [rules.regex(/(^|[^@\w])@(\w{1,15})\b/)]),
|
|
telegram_id: schema.string.optional({}, [rules.regex(/(^|[^@\w])@(\w{1,64})\b/)]),
|
|
});
|
|
|
|
public messages = {
|
|
'phone_number.unique': 'This phone number is not available',
|
|
};
|
|
}
|