---
title: "is_digits"
url: https://una-lang.org/en/docs/std/prelude/is_digits/
release: v0.4.0
edition: "0.1 and later"
source: https://github.com/una-lang/una/blob/v0.4.0/docs/std/listing.json
---

# is_digits

A function of the prelude, in scope in every module. Edition 0.1 and later.

```una
pub is_digits(t: Text) -> Bool
```

Whether every character of `t` is an ASCII digit, so it holds of the empty text (`spec/14 §1`).

## Parameters

- `t`: the text

## Returns

`Bool`: `true` when every character of `t` is an ASCII digit\, so also for the empty text.

## Use instead

- [`parse_int`](https://una-lang.org/en/docs/std/prelude/parse_int/) (edition 0.2 on) to read the number the digits write\, with a reason when there is none

## See also

[`to_int`](https://una-lang.org/en/docs/std/prelude/to_int/)

## Example

`src/shop.una`

```una
module shop

--- Whether a typed article number is one: all digits, and not empty, since the empty text
--- is all digits too.
article(raw: Text) -> Text
=
  let digits = raw.is_digits()
  let valid = raw.len > 0 and digits
  "'{raw}': all digits {digits}, an article number {valid}"

pub main() -> Unit
  uses @console: Console[print]
=
  @console.print(article("12345"))
  @console.print(article("12a45"))
  @console.print(article(""))
```

`una run .` prints:

```text
'12345': all digits true, an article number true
'12a45': all digits false, an article number false
'': all digits true, an article number false
```

## Specification

- [`spec/14 §1`](https://una-lang.org/en/docs/spec/14-standard-library/#s1)

Generated from the standard modules of una v0.4.0 ([`docs/std/listing.json`](https://github.com/una-lang/una/blob/5fec93d88932b333feec25e589355a2cb34c37b5/docs/std/listing.json), which is not part of the specification). The specification governs: [`spec/14 §1`](https://una-lang.org/en/docs/spec/14-standard-library/#s1).
