Home / Function/ string() — svelte Function Reference

string() — svelte Function Reference

Architecture documentation for the string() function in validate-options.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  c50a74b5_34e9_6eba_90e5_52af937ed2fa["string()"]
  1c00ccb7_a603_4a1b_e865_0343036fc5ca["validate-options.js"]
  c50a74b5_34e9_6eba_90e5_52af937ed2fa -->|defined in| 1c00ccb7_a603_4a1b_e865_0343036fc5ca
  68d669a3_acf0_faef_1444_faa0cc8be7d0["validator()"]
  c50a74b5_34e9_6eba_90e5_52af937ed2fa -->|calls| 68d669a3_acf0_faef_1444_faa0cc8be7d0
  be8408ea_8ac5_f7b5_43ee_0abbed48e9bf["throw_error()"]
  c50a74b5_34e9_6eba_90e5_52af937ed2fa -->|calls| be8408ea_8ac5_f7b5_43ee_0abbed48e9bf
  style c50a74b5_34e9_6eba_90e5_52af937ed2fa fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/validate-options.js lines 263–275

function string(fallback, allow_empty = true) {
	return validator(fallback, (input, keypath) => {
		if (typeof input !== 'string') {
			throw_error(`${keypath} should be a string, if specified`);
		}

		if (!allow_empty && input === '') {
			throw_error(`${keypath} cannot be empty`);
		}

		return input;
	});
}

Domain

Subdomains

Frequently Asked Questions

What does string() do?
string() is a function in the svelte codebase, defined in packages/svelte/src/compiler/validate-options.js.
Where is string() defined?
string() is defined in packages/svelte/src/compiler/validate-options.js at line 263.
What does string() call?
string() calls 2 function(s): throw_error, validator.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free