core.isvalidhostname | Medplum
isValidHostname() function
Tests whether a given input is a valid hostname.
NOTE: Does not validate that the input is a valid domain name, only a valid hostname.
Signature:
export declare function isValidHostname(input: string): boolean;
Parameters [](/content/docs/sdk/core.isvalidhostname#parameters "Direct link to Parameters"/index.html)
| Parameter | Type | Description |
|---|---|---|
| input | string | The input to test. |
Returns:
boolean
True if input is a valid hostname, otherwise returns false.
Valid matches:
- foo
- foo.com
- foo.bar.com
- foo.org
- foo.bar.co.uk
- localhost
- LOCALHOST
- foo-bar-baz
- foo_bar
- foobar123
Invalid matches:
foo.com/bar
foo_-bar_-
foo | rm -rf /