Idris2Doc : Text.Html.Elements.Validation

Text.Html.Elements.Validation

(source)
Collection of validation functions for HTML elements.

All these methodes return an `Either` data type.
If there are no errors, the provided input is returnd unchanged as `Right`
value.
If there is an error, an error message is returned as `Left` value.

Definitions

required' : Name -> List Element -> Bool
  Returns `True` if the element's name can be found in the list of elements.

Totality: total
Visibility: public export
required : Name -> List Element -> Either String (List Element)
  Returns either the elements' list or an error message.

An error message is returned if the element's list is empty or if no element
have the provided name.

Totality: total
Visibility: public export
requireds : List Name -> List Element -> Either String (List Element)
  Returns either the elements' list or an error message.

An error message is returned if the element's list does not contain at least
one element of the provided list of name.

Totality: total
Visibility: public export
forbiden : Name -> List Element -> Either String (List Element)
Totality: total
Visibility: public export
forbidens : List Name -> List Element -> Either String (List Element)
Totality: total
Visibility: public export
first : Name -> List Element -> Either String (List Element)
  Returns either the elements' list or an error message.

An error message is returned if the first element of the list doesn't match
the provided name.

Totality: total
Visibility: public export
second : Name -> List Element -> Either String (List Element)
  Returns either the elements' list or an error message.

An error message is returned if the second element of the list doesn't match
the provided name.

Totality: total
Visibility: public export
length : Nat -> List Element -> Either String (List Element)
  Returns either the elements' list or an error message.

An error message is returned if the list's length doesn't match the provided
length.

Totality: total
Visibility: public export
compareWith : (Nat -> Nat -> Bool) -> Name -> Nat -> List Element -> Either String (List Element)
  Returns either the elements' list or an error message.

An error message is returned if the number of occurences of the provided
element name doesn't match the provided count using the provided comparison
operator.

Totality: total
Visibility: public export
count : Name -> Nat -> List Element -> Either String (List Element)
  Returns either the elements' list or an error message.

An error message is returned if the number of occurences of the provided
element name doesn't match the provided count.

Totality: total
Visibility: public export
max : Name -> Nat -> List Element -> Either String (List Element)
  Returns either the elements' list or an error message.

An error message is returned if the number of occurences of the provided
element is higher than the provided count.

Totality: total
Visibility: public export
is : String -> Element -> Either String Element
  Ensures that the element is the expected one.

Totality: total
Visibility: public export
elemOf : List String -> String -> Element -> Either String Element
  Ensures that the `Element`'s name is part of the provided list.

@ listName the name of the list of elements. For example flow content
elements, phrasing content elements, etc.

Totality: total
Visibility: public export
firstOptional : Name -> List String -> String -> List Element -> Either String (List Element)
  Returns either the elements' list or an error message.

An error message is returned if:

- the first element is not the optional element or an element of the list;
- a further element is not an element of the list.

Totality: total
Visibility: public export
firstsOptional : Name -> List String -> String -> List Element -> Either String (List Element)
  Returns either the elements' list or an error message.

An error message is returned if:

- the first elements are not the optional element or an element of the list;
- a further element is not an element of the list.

Totality: total
Visibility: public export
firstOrLastOptional : Name -> List String -> String -> List Element -> Either String (List Element)
  Returns either the elements' list or an error message.

An error message is returned if:

- the first element is not the optional element or an element of the list;
- a further element is not an element of the list;
- the last element is not the optional element or an element of the list;
- the optional element is the first and last element of the list.

Totality: total
Visibility: public export
flowContentElems : List Element -> Either String (List Element)
  Ensures that the `Element`s are flow content elements.

Totality: total
Visibility: public export
listContentElems : Element -> Either String Element
  Ensures that the `Element` is a list content element.

Totality: total
Visibility: public export
meta : Element -> Either String Element
  Ensures that the `Element` is a meta data element.

Totality: total
Visibility: public export
phrasingContentElems : List Element -> Either String (List Element)
  Ensures that all `Element`s are phrasing content elements.

Totality: total
Visibility: public export
flowOrPhrasingContentElems : List Element -> Either String (List Element)
  Ensures that all `Element`s are flow or phrasing content elements.

Totality: total
Visibility: public export
liGlobalAttr : List Element -> Either String (List Element)
  Ensures that **li** elements have only global attributes.

Except for ordered list (**ol**), the **value** attribute has no meaning.
Consequently, only global attributes are allowed for non-ordered lists
(**ul**) and menus (**menu**).

Totality: total
Visibility: public export
metaCharset : List Element -> Either String (List Element)
  Ensures that the first element is **meta** with a **charset** attribute.

Totality: total
Visibility: public export
aElems : List Element -> Either String (List Element)
  Validates an **a** element.

At the exception of **a** elements, accepts:

- flow content
- phrasing content
- interactive content

Totality: total
Visibility: public export
addressElems : List Element -> Either String (List Element)
  Validates an **address** element.

Accepts flow content except for the below elements:

- **address**
- **hgroup**
- **h1** to **h6**
- **article**
- **aside**
- **section**
- **nav**
- **header**
- **footer**

Totality: total
Visibility: public export
audioElems : List Element -> Either String (List Element)
  Validates an **audio** element.

Accepts all content but **audio** or **video**.

Note: this is a simplification, as there are other constraints based on
the presence of a **src* or *source** attribute and the accepted content
is transparent. For more details, see [MDN documentation][1].

[1]: https://developer.mozilla.org/docs/Web/HTML/Reference/Elements/audio

Totality: total
Visibility: public export
canvasElems : List Element -> Either String (List Element)
  Validates a **canvas** element.

Accepts all content but interactive content and the **button** element.

Note: this is a simplification, as this is a transparent element. Also,
interactive content includes other elements depending on the presence of
certain attributes. More details can be found in [MDN documentation][1].

[1]: https://developer.mozilla.org/docs/Web/HTML/Guides/Content_categories#interactive_content

Totality: total
Visibility: public export
colgroupElems : List Element -> Either String (List Element)
  Validates a **colgroup** element.

Accepts only **col** elements.

Note: this is a simplification, as **col** elements are not accepted if
a **span** attribute is present in the **colgroup** element. More details
can be found in [MDN documentation][1].

[1]: https://developer.mozilla.org/docs/Web/HTML/Reference/Elements/colgroup

Totality: total
Visibility: public export
footerElems : List Element -> Either String (List Element)
  Validates a **footer** element.

Accepts flow content except for the **header** and **footer** elements.

Totality: total
Visibility: public export
datalistElems : List Element -> Either String (List Element)
  Validates a **datalist** element.

Accepts phrasing content or **option** elements.

Totality: total
Visibility: public export
detailsElems : List Element -> Either String (List Element)
  Validates a **details** element.

Accepts a **summary** element followed by flow content.

Totality: total
Visibility: public export
dfnElems : List Element -> Either String (List Element)
  Validates a **dfn** element.

Accepts phrasing content except for the **dfn** element.

Totality: total
Visibility: public export
divElems : List Element -> Either String (List Element)
  Validates a **div** element.

Accepts flow content as well as the below additional elements:

- **dt**
- *dd**
- **script**
- **template**.

Note: this is a simplification, as normally those additional elements can
only be present if the parent is a **dl** element. Also, the **script** and
are intermixed with **dd** elements. See [MDN documentation][1] for more
details.

[1]: https://developer.mozilla.org/docs/Web/HTML/Reference/Elements/div

Totality: total
Visibility: public export
dlElems : List Element -> Either String (List Element)
  Validates a **dl** element.

Accepts **dt**, *dd**, **script** or **template** elements.

This is a supplication. See [MDN documentation][1] for more details.

[1]: https://developer.mozilla.org/docs/Web/HTML/Reference/Elements/dl

Totality: total
Visibility: public export
dtElems : List Element -> Either String (List Element)
  Validates a **dt** element.

Accepts flow content except for the below:

- **header** element
- **footer** element
- sectioning content
- heading content.

Totality: total
Visibility: public export
fieldsetElems : List Element -> Either String (List Element)
  Validates a **fieldset** element.

Accepts an optional **legend** followed by flow content.

Totality: total
Visibility: public export
figureElems : List Element -> Either String (List Element)
  Validates a **figure** element.

Accepts an optional **figcaption** element which must either be at the
beginning or the end of the children list.
The other children must be flow content elements.

Totality: total
Visibility: public export
formElems : List Element -> Either String (List Element)
  Validates a **form** element.

Accepts flow content but no **form** element.

Totality: total
Visibility: public export
headElems : List Element -> Either String (List Element)
  Validates a **head** element.

Accepts meta elements and one **title** element.
Also, the first element must be **meta** with a **charset** attribute.

Totality: total
Visibility: public export
headerElems : List Element -> Either String (List Element)
  Validates a **header** element.

Accepts flow content except for **header** or **footer** elements.

Totality: total
Visibility: public export
hgroupElems : List Element -> Either String (List Element)
  Validates a **hgroup** element.

Accepts zero or more **p** elements followed by one **h1** to **h6**
element, followed by zero or more **p** elements.

Totality: total
Visibility: public export
htmlElems : List Element -> Either String (List Element)
  Validates the **html** element.

Accepts one **head** element followed by a **body** element.

Totality: total
Visibility: public export
labelElems : List Element -> Either String (List Element)
  Validates a **label** element.

Accepts phrasing content except for **label** elements.

Note: it is a simplification, as actually no labelable elements other than
the labeled control are allowed.
See [MDN documentation][1] for more details.

[1]: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/label

Totality: total
Visibility: public export
legendElems : List Element -> Either String (List Element)
  Validates a **legend** element.

Accepts phrasing content as well as **h1** to **h6** elements.

Totality: total
Visibility: public export
meterElems : List Element -> Either String (List Element)
  Validates a **meter** element.

Accepts phrasing content except for **meter** elements.

Totality: total
Visibility: public export
noscriptElems : List Element -> Either String (List Element)
  Validates a **noscript** element.

Accepts flow content, phrasing content as well as **link**, **style** and
**meta** elements.

Note: it is a simplification, as the allowed content depends on the parent
of the **noscript** element. See [MDN documentation][1] for more details.

[1]: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/noscript

Totality: total
Visibility: public export
objectElems : List Element -> Either String (List Element)
  Validates the **object** element.

Accepts zero or more **param** elements followed by flow or phrasing
content.

Note: it is a simplification, as normally the allowed content is
transparent. See [MDN documentation][1] for more details.

[1]: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/object

Totality: total
Visibility: public export
optgroupElems : List Element -> Either String (List Element)
  Validates the **optgroup** element.

Accepts zero or more **option** elements.

Note: no **legend** element is authorised as customizable select elements is
not considered as "baseline" due to the lack of support by some browsers.
See [MDN documentation][1] for more details.

[1]: https://developer.mozilla.org/docs/Learn_web_development/Extensions/Forms/Customizable_select

Totality: total
Visibility: public export
pictureElems : List Element -> Either String (List Element)
  Validates the **picture** element.

Accepts zero or more **source** elements followed by one **img** element.
Those elements can be mixed with script-supporting elements.

Totality: total
Visibility: public export
plaintextElems : List Element -> Either String (List Element)
  Accepts only plain text.

Used for the validation of the **option** and **rp** elements.

Totality: total
Visibility: public export
progressElems : List Element -> Either String (List Element)
  Validates a **progress** element.

Accepts phrasing content elements, except **progress** elements.

Totality: total
Visibility: public export
rubyElems : List Element -> Either String (List Element)
  Validates a **ruby** element.

Accepts phrasing content as well as **rp** and **rt** elements.

Note: it is a simplification, as the allowed content is in reality one or
more groups consisting of two parts. See [MDN documentation][1] for more
details.

[1]: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ruby

Totality: total
Visibility: public export
ulElems : List Element -> Either String (List Element)
  Validates a **ul** element.

Accepts list content elements. Also, the list elements within **ul** can
only have global attributes.

Totality: total
Visibility: public export
scriptElems : List Element -> Either String (List Element)
  Validates a **script** element.

Accepts only script content.

Totality: total
Visibility: public export
selectElems : List Element -> Either String (List Element)
  Validates a **select** element.

Accept only **option**, **optgroup**, **hr**, **button**, **div**,
**script**, **template**, **noscript** or **select** elements.

Also, there can be no more than one **button** element.

Note: this is a simplification, as the **button** must precede the
**option**, **optgroup** and **hr** elements. See [MDN documention][1] for
more details.

[1]: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/select

Totality: total
Visibility: public export
slotElems : List Element -> Either String (List Element)
  Validates a **slot** element.

Accepts flow or phrasing content.

Note: this is a simplification as the content is transparent.

Totality: total
Visibility: public export
styleElems : List Element -> Either String (List Element)
  Validates a **style** element.

Accepts only CSS content.

Totality: total
Visibility: public export
summaryElems : List Element -> Either String (List Element)
  Validates a **summary** element.

Accepts phrasing or heading content.

Totality: total
Visibility: public export
tableElems : List Element -> Either String (List Element)
  Validates a **table** element.

Accepts:

- first, an optional **caption** element;
- then, zero ore more **colgroup** elements;
- then, an optional **thead** element;
- then, either one or more:
- **tbody** elements; or
- **tr** elements; or
- then, an optional **tfoot** element.

Totality: total
Visibility: public export
tbodyElems : List Element -> Either String (List Element)
  Validates a **tbody** element.

Accepts only **tr** elements.

Totality: total
Visibility: public export
templateElems : List Element -> Either String (List Element)
  Validates a **template** element.

Accepts all elements except **html**, **head** and **body**.

Totality: total
Visibility: public export
thElems : List Element -> Either String (List Element)
  Validates a **th** element.

Accepts flow content elements except **header** or **footer** elements or
heading or sectioning content.

Totality: total
Visibility: public export
trElems : List Element -> Either String (List Element)
  Validates a **tr** element.

Accepts **th**, **td**, **script** or **template** elements

Totality: total
Visibility: public export
videoElems : List Element -> Either String (List Element)
  Validates a **video** element.

If the **video** element has a **src** attribute, accepts:

- zero or more **source** elements; and then
- zero or more **track** elements; and then
- flow, phrasing, embedded or interactive content.

None of the above can contain **video** or **audio** elements.

Note: this is a simplification, as this element can be transparent and
the allowed elements depend on its attributes.

Totality: total
Visibility: public export