pip_services3_commons.validate.PropertySchema module
pip_services3_commons.validate.PropertySchema
Validation schema for object properties
- copyright
Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.
- license
MIT, see LICENSE for more details.
-
class
pip_services3_commons.validate.PropertySchema.
PropertySchema
(name: str = None, value_type: Any = None, required: bool = None, rules: List[pip_services3_commons.validate.IValidationRule.IValidationRule] = None) Bases:
pip_services3_commons.validate.Schema.Schema
Schema to validate object properties
Example:
schema = ObjectSchema().with_property(PropertySchema("id", TypeCode.String)) schema.validate({ id: "1", name: "ABC" }) # Result: no errors schema.validate({ name: "ABC" }) # Result: no errors schema.validate({ id: 1, name: "ABC" }) # Result: id type mismatch
-
get_type
() → Any Gets the property type.
- Returns
the property type.
-