Skip to content

Conversation

@aweikalee
Copy link

import { IsOptional, Equals, ClassPropertyTitle, validator } from 'class-validator-multi-lang';

class Parent {
  @IsOptional()
  @Equals('test')
  @ClassPropertyTitle('property "title"')
  title: string = 'bad_value';
}

class MyClass extends Parent {}

const RU_I18N_MESSAGES = {
  '$property must be equal to $constraint1': '$property должно быть равно $constraint1',
};
const RU_I18N_TITLES = {
  'property "title"': 'поле "заголовок"',
};

const model = new MyClass();

validator.validate(model, { messages: RU_I18N_MESSAGES, titles: RU_I18N_TITLES }).then(errors => {
  console.log(errors[0].constraints);
  // now out: title должно быть равно test
  // expect out: поле "заголовок" должно быть равно test
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant