new Checksum(dataopt)
Create a Checksum instance.
Parameters:
| Name |
Type |
Attributes |
Description |
data |
object
|
<optional>
|
Initial checksum values.
Properties
| Name |
Type |
Attributes |
Description |
value |
string
|
null
|
<optional>
|
Checksum value. |
algorithm |
string
|
null
|
<optional>
|
Checksum algorithm. |
|
- Source:
Methods
Clear the checksum value and algorithm.
- Source:
Returns:
The same checksum instance.
-
Type
-
Checksum
isEmpty() → {boolean}
Whether the checksum is empty.
- Source:
Returns:
`true` when neither value nor algorithm is present.
-
Type
-
boolean
Normalize the checksum in place.
- Source:
Returns:
The same checksum instance.
-
Type
-
Checksum
set(value, algorithm) → {Checksum}
Set the checksum value and algorithm.
Parameters:
| Name |
Type |
Description |
value |
string
|
null
|
Checksum value. |
algorithm |
string
|
null
|
Checksum algorithm. |
- Source:
Returns:
The same checksum instance.
-
Type
-
Checksum
toElement(doc) → {Element|null}
Serialize the checksum to XML.
Parameters:
| Name |
Type |
Description |
doc |
XMLDocument
|
XML document used to create elements. |
- Source:
Returns:
Serialized XML element, or `null` when empty.
-
Type
-
Element
|
null
toJSON() → {object|null}
Return a JSON-serializable representation of the checksum.
- Source:
Returns:
Plain checksum data, or `null` when empty.
-
Type
-
object
|
null
validate(pathopt) → {Array.<object>}
Validate the checksum state.
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
path |
string
|
<optional>
|
checksum
|
Base path used in validation errors. |
- Source:
Returns:
Validation errors for invalid fields.
-
Type
-
Array.<object>
fromElement(element) → {Checksum}
Create a Checksum from a `checksum` XML element.
Parameters:
| Name |
Type |
Description |
element |
Element
|
XML element to parse. |
- Source:
Returns:
Parsed checksum instance.
-
Type
-
Checksum
fromValue(value) → {Checksum}
Coerce unknown input into a Checksum instance.
Parameters:
| Name |
Type |
Description |
value |
Checksum
|
object
|
null
|
undefined
|
Checksum-like input. |
- Source:
Returns:
Normalized checksum instance.
-
Type
-
Checksum
parse(element) → {Checksum}
Parse a `checksum` XML element.
Parameters:
| Name |
Type |
Description |
element |
Element
|
null
|
XML element to parse. |
- Source:
Returns:
Parsed checksum instance.
-
Type
-
Checksum