Validation rule to check that a list contains only specified values.

Inherits: IValidationRule


The InclidedRule class allows you to check that a list contains only specified values.


Creates a new validation rule and sets its values.

public IncludedRule(params object[] values)

  • values: object[] - a list of constants that value must be included to

Instance methods


Validates a given value against this rule.

public void Validate(string path, Schema schema, object value, List<ValidationResult> results)

  • path: string - a dot notation path to the value.
  • schema: Schema - a schema this rule is called from
  • value: object - a value to be validated.
  • results: List<ValidationResult> - a list with validation results to add new results.


var schema = new Schema().WithRule(new IncludedRule(1, 2, 3));

schema.Validate(2);      // Result: no errors
schema.Validate(10);     // Result: 10 must be one of 1, 2, 3

See also