Validation
Initialization
To initialize a validator load a dictionary and create validators for different rules you need to check.
IValidatorFactory validatorFactory = ValidatorFactory.CreateFactory(FixVersion.Fix44, FixVersion.Fix44);
IValidatorContainer validators = validatorFactory.CreateRequiredValidator();
validators.PutNewValidator(ValidatorType.MessageWelformed, validatorFactory.CreateValidator(ValidatorType.MessageWelformed));
validators.PutNewValidator(ValidatorType.FieldAllowed, validatorFactory.CreateValidator(ValidatorType.FieldAllowed));
validators.PutNewValidator(ValidatorType.RequiredFields, validatorFactory.CreateValidator(ValidatorType.RequiredFields));
validators.PutNewValidator(ValidatorType.FieldOrder, validatorFactory.CreateValidator(ValidatorType.FieldOrder));
validators.PutNewValidator(ValidatorType.Duplicate, validatorFactory.CreateValidator(ValidatorType.Duplicate));
validators.PutNewValidator(ValidatorType.FieldDefinition, validatorFactory.CreateValidator(ValidatorType.FieldDefinition));
validators.PutNewValidator(ValidatorType.Conditional, validatorFactory.CreateValidator(ValidatorType.Conditional));
validators.PutNewValidator(ValidatorType.Group, validatorFactory.CreateValidator(ValidatorType.Group));
IFixMessageValidator validator = new ValidationEngine(validators);
Validation
To validate a message:
// get Fix message
FixMessage fieldList = ...;
FixErrorContainer errors = validator.ValidateFixMessage(fieldList);
//print all errors
for (FixError error in errors.GetAllFixErrors())
{
Console.WriteLine(error);
}
//print high error
Console.WriteLine(errors.GetIsPriorityFixError());