pip_services3_commons.validate.ArraySchema module

pip_services3_commons.validate.ArraySchema

Array schema implementation

copyright

Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.

license

MIT, see LICENSE for more details.

class pip_services3_commons.validate.ArraySchema.ArraySchema(value_type: Any = None, required: bool = None, rules: Sequence[pip_services3_commons.validate.IValidationRule.IValidationRule] = None)

Bases: pip_services3_commons.validate.Schema.Schema

Schema to validate arrays.

Example:

schema = ArraySchema(TypeCode.String)

schema.validate(["A", "B", "C"])    # Result: no errors
schema.validate([1, 2, 3])          # Result: element type mismatch
schema.validate("A")                # Result: type mismatch
get_value_type() → Any

Gets the type of array elements. Null means that elements may have any type.

Returns

the type of array elements.

set_value_type(value: Any)

Sets the type of array elements. Null means that elements may have any type.

Parameters

value – a type of array elements.