How to use the voluptuous.And function in voluptuous

To help you get started, we’ve selected a few voluptuous examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / aries-protocol-test-suite / protocol_tests / connection / __init__.py View on Github external
VALIDATOR = Schema({
        "@context": "https://w3id.org/did/v1",
        "id": str,
        "publicKey": [PUBLIC_KEY_VALIDATOR],
        # This is not fully correct; see:
        # https://w3c.github.io/did-core/#authentication
        Optional("authentication"): [
            {
                "type": "Ed25519SignatureAuthentication2018",
                "publicKey": str
            },
            PUBLIC_KEY_VALIDATOR,
            str
        ],
        "service": And(
            # Service contains at least one agent service
            AtLeastOne(
                {
                    'id': Match('.*;{}$'.format(EXPECTED_SERVICE_SUFFIX)),
                    'type': EXPECTED_SERVICE_TYPE,
                    'priority': int,
                    'recipientKeys': [str],
                    Optional('routingKeys'): [str],
                    'serviceEndpoint': str
                },
                msg='DID Communication service missing'
            ),
            # And all services match DID Spec
            [
                {
                    "id": str,
github openstack / monasca-analytics / monasca_analytics / ingestor / cloud.py View on Github external
def validate_config(_config):
        cloud_schema = voluptuous.Schema({
            "module": voluptuous.And(six.string_types[0],
                                     vu.NoSpaceCharacter())
        }, required=True)
        return cloud_schema(_config)
github openstack / monasca-analytics / monasca_analytics / sml / svc.py View on Github external
def validate_config(_config):
        svc_schema = voluptuous.Schema({
            'module': voluptuous.And(six.string_types[0],
                                     NoSpaceCharacter()),
            'nb_samples': voluptuous.Or(float, int)
        }, required=True)
        return svc_schema(_config)
github openstack / monasca-analytics / monasca_analytics / source / randoms.py View on Github external
"params": {
                        "origin_types": voluptuous.And([
                            {
                                "origin_type": voluptuous.And(
                                    six.string_types[0],
                                    vu.NoSpaceCharacter()),
                                "weight": voluptuous.And(
                                    voluptuous.Or(int, float),
                                    voluptuous.Range(
                                        min=0, min_included=False)),
                            }
                        ], vu.NotEmptyArray()),
                        voluptuous.Optional("key_causes"): dict
                    }
                },
                "alerts_per_burst": voluptuous.And(
                    int, voluptuous.Range(min=1)),
                "idle_time_between_bursts": voluptuous.And(
                    voluptuous.Or(int, float),
                    voluptuous.Range(min=0, min_included=False))
            }
        }, required=True)
        return source_schema(_config)
github openstack / monasca-analytics / monasca_analytics / source / iptables_markov_chain.py View on Github external
def validate_config(_config):
        source_schema = voluptuous.Schema({
            "module": voluptuous.And(six.string_types[0],
                                     vu.NoSpaceCharacter()),
            "sleep": voluptuous.And(
                float,
                voluptuous.Range(
                    min=0, max=1, min_included=False, max_included=False)),
        }, required=True)
        return source_schema(_config)
github openstack / monasca-analytics / monasca_analytics / sml / svm_one_class.py View on Github external
def validate_config(_config):
        svm_schema = voluptuous.Schema({
            "module": voluptuous.And(six.string_types[0],
                                     vu.NoSpaceCharacter()),
            "nb_samples": voluptuous.Or(float, int)
        }, required=True)
        return svm_schema(_config)
github openstack / monasca-analytics / monasca_analytics / sml / lingam.py View on Github external
def validate_config(_config):
        lingam_schema = voluptuous.Schema({
            "module": voluptuous.And(six.string_types[0],
                                     vu.NoSpaceCharacter()),
            "threshold": float
        }, required=True)
        return lingam_schema(_config)
github openstack / monasca-analytics / monasca_analytics / sml / elliptic_envelope.py View on Github external
def validate_config(_config):
        elliptic_schema = voluptuous.Schema({
            'module': voluptuous.And(six.string_types[0],
                                     NoSpaceCharacter()),
            'nb_samples': voluptuous.Or(float, int)
        }, required=True)
        return elliptic_schema(_config)
github openstack / monasca-analytics / monasca_analytics / voter / pick_index.py View on Github external
def validate_config(_config):
        pick_schema = voluptuous.Schema({
            "module": voluptuous.And(
                six.string_types[0],
                lambda i: not any(c.isspace() for c in i)),
            "index": voluptuous.And(
                voluptuous.Or(float, int),
                lambda i: i >= 0 and math.ceil(i) == math.floor(i)
            )
        }, required=True)
        return pick_schema(_config)