All built in validators are in the SampleService.core.validator.builtin module.
Example configuration:
validators:
metadatakey:
validators:
- module: SampleService.core.validator.builtin
callable_builder: noopThis validator accepts any and all values.
Example configuration:
validators:
metadatakey:
validators:
- module: SampleService.core.validator.builtin
callable_builder: string
parameters:
keys: ['key1', 'key2']
required: True
max-len: 10keysis either a string or a list of strings and determines which keys will be checked by the validator. If the key exists, its value must be a string orNone(nullin JSON-speak).requiredrequires any keys in thekeysfield to exist in the map, although their value may still beNone.max-lendetermines the maximum length in characters of the values of the keys listed inkeys. Ifkeysis not supplied, then it determines the maximum length of all keys and string values in the metadata value map.
Example configuration:
validators:
metadatakey:
validators:
- module: SampleService.core.validator.builtin
callable_builder: enum
parameters:
keys: ['key1', 'key2']
allowed-values: ['red', 'blue', 'green]allowed-valuesis a list of primitives - strings, integers, floats, or booleans - that are allowed metadata values. Ifkeysis not supplied, all values in the metadata value mapping must be one of the allowed values.keysis either a string or a list of strings and determines which keys will be checked by the validator. The key must exist and its value must be one of theallowed-values.
Example configuration:
validators:
metadatakey:
validators:
- module: SampleService.core.validator.builtin
callable_builder: units
parameters:
key: 'units'
units: 'mg/L'keyis the metadata value key that will be checked against theunitsspecification.unitsis a unit specification in the form of an example. Any units that can be converted to the given units will be accepted. For example, ifunitsisK, thendegF,degC, anddegRare all acceptable input to the validator. Similarly, ifNis given,kg * m / s^2andlb * f / s^2are both acceptable.
Example configuration:
validators:
metadatakey:
validators:
- module: SampleService.core.validator.builtin
callable_builder: number
parameters:
keys: ['length', 'width']
type: int
required: True
gte: 42
lt: 77Ensures all values are integers or floats.
keys, which is either a string or a list of strings, determines which keys in the metadata value map are checked. If omitted, all keys are checked.- If
requiredis specified, the keys in thekeyslist must exist in the metadata value map, although their value may benull. typespecifies that the number or numbers must be integers if set tointor any number if omitted or set tofloatornull.gt,gte,lt, andlteare respectively greater than, greater than or equal, less than, and less than or equal, and specify a range in which the number or numbers must exist. Ifgtorltare specified,gteorltecannot be specified, respectively, and vice versa.
Example configuration:
validators:
metadatakey:
validators:
- module: SampleService.core.validator.builtin
callable-builder: ontology_has_ancestor
parameters:
ontology: 'envo_ontology'
ancestor_term: 'ENVO:00010483'
srv_wiz_url: 'https://kbase.us/services/service_wizard'ontologyis the ontology that the meta value will be checked against.ancestor_termis the ancestor ontology term that will be used to check whether meta value has such ancestor or not.srv_wiz_urlis the kbase service wizard url for getting OntologyAPI service.