class Validator:
Validator class.
| Method | add |
Add a new attribute policy for normal resources. |
| Method | add |
Add a single new policy dictionary for a type's attributes. |
| Method | add |
Add flexContainer specialization information to the internal dictionary. |
| Method | clear |
Clear the attribute policies. |
| Method | clear |
Clear the flexContainer attributes. |
| Method | clear |
Clear the flexContainer specialization information. |
| Method | convert |
Convert an attribute to the Absolute or SP-relative form if it is an identifier. This is a recursive function that is called for each attribute of a complex attribute (e.g. a list or a complex attribute). |
| Method | convert |
Convert identifier attributes to the specified scope. |
| Method | get |
Return all attribute policies. |
| Method | get |
Return the attribute policies for an attribute name. |
| Method | get |
Return the attributePolicy for a resource type. |
| Method | get |
Return the name of an attribute value. This is usually used for enumerations, where the value is a number and the name is a string. |
| Method | get |
Return the representation of an attribute value. This is usually used for the representation of an attribute where the value is not known yet. |
| Method | get |
Return the attribute policies for a complex type. |
| Method | get |
Return the interpretation of an enumeration. |
| Method | get |
Return the attribute policies for a flexContainer specialization. |
| Method | get |
Return the availale data for a flexContainer specialization. |
| Method | get |
Return the shortname to longname mappings. |
| Method | has |
Test whether a flexContainer specialization with a containerDefinition exists. |
| Method | initialize |
Initialize the validator. |
| Method | is |
Check whether the resource attribute attr is neither a universal, common, or resource attribute, nor an internal attribute. |
| Method | shutdown |
Shutdown the validator. |
| Method | update |
Add or update new specialization attribute definitions to the validator. The dict has a single entry (the type) that contains another dict of attribute policies for that type. |
| Method | validate |
Validate a single attribute. |
| Method | validate |
Validate a resources' attributes for types etc. |
| Method | validate |
Validate the contents of the contentInfo attribute. |
| Method | validate |
Validate the format of a CSE-ID in csi or cb attributes. |
| Method | validate |
Validate a GeoJSON line or polygon. A line or polygon is a list of lists of two or three floats. |
| Method | validate |
Validate a GeoJSON location. A location is a dictionary with a type and coordinates. |
| Method | validate |
Validate a GeoJSON multi line or polygon. A line or polygon is a list of list of lists of two or three floats. |
| Method | validate |
Validate a GeoJSON point. A point is a list of two or three floats. |
| Method | validate |
Validate the primitive content. |
| Method | validate |
Validating special case for lists that are not allowed to be empty (pvs in ACP). |
| Method | validate |
Validate a resource update dictionary. Besides of the attributes it also validates the resource type. |
| Class Variable | cnf |
Compiled regular expression that matches a valid contentInfo string. |
| Class Variable | importer |
Injected Importer instance. |
| Method | _validate |
Check a value for its type. |
| Class Variable | _nc |
Disallowed characters in NCName. |
| Class Variable | _schedule |
"second minute hour day month weekday year" |
| Class Variable | _token |
Disallowed characters in token. |
Add a single new policy dictionary for a type's attributes.
This is done by either creating a new entry, or adding the new policy to the existing policies and then updating the old entry in the global dictionary.
| Parameters | |
policy:AttributePolicy | AttributePolicy dictionary with a single attribute policy. |
| Returns | |
bool | Boolean, indicating whether a policy was added successfully. |
Add flexContainer specialization information to the internal dictionary.
| Parameters | |
typestr | String, domain and short name of the flexContainer specialization. |
cnd:str | String, the containerDefinition of the flexContainer specialization. |
lname:str | String, the long name of the flexContainer specialization. |
| Returns | |
bool | Boolean, indicating whether a specialization was added successfully. |
Any, typ: BasicType, policy: AttributePolicy, scope: IdentifierScope | None = IdentifierScope.SPRelative) -> Any:
¶
Convert an attribute to the Absolute or SP-relative form if it is an identifier. This is a recursive function that is called for each attribute of a complex attribute (e.g. a list or a complex attribute).
| Parameters | |
value:Any | The value to convert. |
typ:BasicType | The type of the value. |
policy:AttributePolicy | The attribute policy of the value. |
scope:IdentifierScope | None | The scope of the conversion |
| Returns | |
Any | The converted value. |
Convert identifier attributes to the specified scope.
This method is called recursively for each attribute of a complex attribute (e.g. a list or a complex attribute).
| Parameters | |
k:str | Attribute name. |
v:JSON | Attribute value. |
typ:ResourceTypes | Resource type of the attribute. |
scope:IdentifierScope | Scope to convert to. |
| Returns | |
Any | The converted value. |
Return all attribute policies.
| Returns | |
ResourceAttributePolicyDict | Dictionary with all attribute policies. |
Return the attribute policies for an attribute name.
| Parameters | |
attr:str | Attribute name. |
| Returns | |
list[ | List of AttributePolicy or None. |
ResourceTypes | str, attr: str, specific: bool = False) -> AttributePolicy:
¶
Return the attributePolicy for a resource type.
| Parameters | |
rtype:ResourceTypes | str | Resource type to check first. |
attr:str | Attribute name. |
specific:bool | Boolean, indicating whether to search for a specific type. |
| Returns | |
AttributePolicy | AttributePolicy or None. |
str, value: int, rtype: ResourceTypes | None = None) -> str:
¶
Return the name of an attribute value. This is usually used for enumerations, where the value is a number and the name is a string.
This method is mainly used for the interpretation of enumeration values in the UIs.
| Parameters | |
attr:str | Attribute name. |
value:int | Attribute value. |
rtype:ResourceTypes | None | Undocumented |
| Returns | |
str | String, name of the attribute value. |
str, resourceType: ResourceTypes, withComments: bool | None = True) -> str:
¶
Return the representation of an attribute value. This is usually used for the representation of an attribute where the value is not known yet.
| Parameters | |
attr:str | Attribute name. |
resourceResourceTypes | Type of the attribute's resource. |
withbool | None | Boolean, indicating whether to include comments in the representation. |
| Returns | |
str | String, representation of the attribute value. This might be a JSON representation of the value. |
Return the attribute policies for a complex type.
| Parameters | |
ctype:str | Complex type name. |
| Returns | |
list[ | List of AttributePolicy or None. |
Return the interpretation of an enumeration.
| Parameters | |
rtype:ResourceTypes | Resource type. May be None. |
attr:str | Attribute name. |
value:int | Enumeration value. |
| Returns | |
str | String, interpretation of the enumeration, or the value itself if no interpretation is available. |
Return the attribute policies for a flexContainer specialization.
| Parameters | |
typestr | String, domain and short name of the flexContainer specialization. |
| Returns | |
AttributePolicyDict | Dictictionary of additional attributes for a flexCOntainer type or None. |
Return the availale data for a flexContainer specialization.
| Parameters | |
typestr | String, domain and short name of the flexContainer specialization. |
| Returns | |
tuple[ | Tuple with the flexContainer specialization data (or None if none exists). The tuple contains the containerDefinition and the long name. |
Return the shortname to longname mappings.
| Returns | |
dict[ | Dictionary with the shortname to longname mappings. |
Test whether a flexContainer specialization with a containerDefinition exists.
| Parameters | |
cnd:str | String, containerDefinition |
| Returns | |
bool | Boolean, indicating existens. |
Add or update new specialization attribute definitions to the validator. The dict has a single entry (the type) that contains another dict of attribute policies for that type.
str, value: Any, attributeType: BasicType | None = None, rtype: ResourceTypes | None = ResourceTypes.ALL) -> tuple[ BasicType, Any]:
¶
Validate a single attribute.
| Parameters | |
attribute:str | Name of the attribute to perform the check. |
value:Any | Value to validate for the attribute. |
attributeBasicType | None | If attributeType is set then that type is taken to perform the check, otherwise the attribute type is determined. |
rtype:ResourceTypes | None | Some attributes' validations depend on the resource type. |
| Returns | |
tuple[ | A tuple with determined data type and the converted value. |
| Raises | |
BAD_REQUEST | If the validation fails. |
JSON, typeShortname: str, ty: ResourceTypes | None = ResourceTypes.UNKNOWN, attributes: AttributePolicyDict | None = None, create: bool | None = True, createdInternally: bool | None = False, isAnnounced: bool | None = False):
¶
Validate a resources' attributes for types etc.
| Parameters | |
resource:JSON | dictionary to check |
typestr | The resource's resource type name |
ty:ResourceTypes | None | The resource type |
attributes:AttributePolicyDict | None | The attribute policy dictionary for the resource type. If this is None then validate automatically |
create:bool | None | Boolean indicating whether this a CREATE request |
createdbool | None | Boolean indicating that a resource is created internally |
isbool | None | Boolean indicating that a resource is announced |
| Returns | |
| Result object |
Validate the format of a CSE-ID in csi or cb attributes.
| Parameters | |
val:str | The value to validate. |
name:str | The name of the attribute. |
Validate a GeoJSON line or polygon. A line or polygon is a list of lists of two or three floats.
| Parameters | |
geo:dict | GeoJSON string line or polygon. |
isbool | None | Boolean, indicating whether the coordinates describe a polygon. |
| Returns | |
bool | Boolean, indicating whether the line or polygon is valid. |
Validate a GeoJSON location. A location is a dictionary with a type and coordinates.
| Parameters | |
loc:dict | GeoJSON location. |
| Returns | |
dict | The validated location dictionary. |
| Raises | |
BAD_REQUEST | If the location definition is invalid. |
Validate a GeoJSON multi line or polygon. A line or polygon is a list of list of lists of two or three floats.
| Parameters | |
geo:dict | GeoJSON string multi line or polygon. |
isbool | None | Boolean, indicating whether the coordinates describe a polygon. |
| Returns | |
bool | Boolean, indicating whether the line or polygon is valid. |
Validate a GeoJSON point. A point is a list of two or three floats.
| Parameters | |
geo:dict | GeoJSON point. |
| Returns | |
bool | Boolean, indicating whether the point is valid. |
Validate the primitive content.
| Parameters | |
pc:JSON | The primitive content to validate. |
elementstr | Undocumented |
Resource, dct: JSON, doValidateAttributes: bool = False):
¶
Validate a resource update dictionary. Besides of the attributes it also validates the resource type.
See Also
| Parameters | |
resource:Resource | The resource to validate the update request for. |
dct:JSON | The JSON dictionary of the update request. |
dobool | Boolean indicating whether to validate the attributes. |
| Returns | |
| None |
BasicType, value: Any, convert: bool | None = False, policy: AttributePolicy | None = None) -> tuple[ BasicType, Any]:
¶
Check a value for its type.
| Parameters | |
dataBasicType | Required data type for the value to check against. |
value:Any | Value to validate. |
convert:bool | None | If the convert parameter is True then it is assumed that the value could be a stringified value and the method will attempt to convert the value to its target type; otherwise this is an error. |
policy:AttributePolicy | None | Undocumented |
| Returns | |
Result. If the check is positive then a tuple is returned | (the determined data type, the converted value). |
| Raises | |
BAD_REQUEST | If the validation fails. |