legalize
1.2.2, released 3 years ago by caesarovich.xyz
Provides functions to validate and sanitize filenames for various operating systems.
WASM-ready
What it does
The package checks filenames against OS-specific restrictions and can remove or replace illegal characters. It offers both validation and sanitization helpers for Windows, macOS/iOS (HFS), Android (FAT), and POSIX systems.
AI-written summary of version 1.2.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to ensure filenames are safe before saving them on disk
- You support multiple platforms and want a single API for filename rules
Skip it when
- You require advanced filesystem features beyond basic character checks
- You need real-time streaming validation of filenames
Strengths
- Covers major OS filename rules in one library
- Simple, zero‑dependency API
- Allows custom control‑character handling
Weaknesses
- Limited to character sanitization, no path handling
- Package is still marked as in development
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:legalize/legalize.dart';
void main() {
const someFilename = 'my?/?/?File.txt';
final sanitized = legalizeFilename(someFilename);
print(sanitized); // myFile.txt
}Alternatives
Packages that do the same job and could replace legalize.
- bad_words
A Dart filter to check if a string contains English bad words and clean them.
40Compare - sanitize_filename
Sanitizes strings by removing or replacing characters illegal for filenames.
30Compare