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