mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 18:29:15 +03:00
32 lines
972 B
TypeScript
32 lines
972 B
TypeScript
import { schema, rules } from '@ioc:Adonis/Core/Validator';
|
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
|
|
|
export default class UpdateUserValidator {
|
|
constructor(protected ctx: HttpContextContract) {}
|
|
|
|
public schema = schema.create({
|
|
name: schema.string.optional(),
|
|
surname: schema.string.optional(),
|
|
patronymic: schema.string.optional(),
|
|
login: schema.string.optional(),
|
|
email: schema.string.optional({}, [
|
|
rules.email(),
|
|
rules.unique({ table: 'users', column: 'email' }),
|
|
]),
|
|
password: schema.string.optional(),
|
|
});
|
|
|
|
/**
|
|
* Custom messages for validation failures. You can make use of dot notation `(.)`
|
|
* for targeting nested fields and array expressions `(*)` for targeting all
|
|
* children of an array. For example:
|
|
*
|
|
* {
|
|
* 'profile.username.required': 'Username is required',
|
|
* 'scores.*.number': 'Define scores as valid numbers'
|
|
* }
|
|
*
|
|
*/
|
|
public messages = {};
|
|
}
|