Gathering detailed insights and metrics for @doubter/plugin-string-format
Gathering detailed insights and metrics for @doubter/plugin-string-format
🤔 String format validation plugin for Doubter.
npm install @doubter/plugin-string-format
Typescript
Module System
Node Version
NPM Version
73.3
Supply Chain
98.8
Quality
77.3
Maintenance
100
Vulnerability
100
License
TypeScript (97.84%)
JavaScript (2.16%)
Total Downloads
1,082
Last Day
1
Last Week
1
Last Month
41
Last Year
674
17 Commits
2 Watching
2 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
3.1.0
Package Id
@doubter/plugin-string-format@3.1.0
Unpacked Size
42.16 kB
Size
6.79 kB
File Count
39
NPM Version
10.8.2
Node Version
20.18.0
Publised On
25 Oct 2024
Cumulative downloads
Total Downloads
Last day
-66.7%
1
Compared to previous day
Last week
-92.9%
1
Compared to previous week
Last month
70.8%
41
Compared to previous month
Last year
65.2%
674
Compared to previous year
String format validation plugin for Doubter.
1npm install --save-prod doubter @doubter/plugin-string-format
Import and enable the plugin:
1import * as d from 'doubter'; 2import '@doubter/plugin-string-format'; 3 4const emailShape = d.string().email(); 5 6emailShape.parse('foo@bar.com'); 7// ⮕ 'foo@bar.com' 8 9emailShape.parse('foo'); 10// ❌ ValidationError: string.format.email at /: Must be an email
Or cherry-pick separate format checkers:
1import * as d from 'doubter'; 2// 🟡 Import a single format module 3import '@doubter/plugin-string-format/bic'; 4 5const bicShape = d.string().bic(); 6 7bicShape.parse('BOFAUS3N'); 8// ⮕ 'BOFAUS3N' 9 10bicShape.parse('QUX'); 11// ❌ ValidationError: string.format.bic at /: Must be a BIC or SWIFT code
Format checks raise issues with "string.format.*"
code.
1d.string().email().try('foo');
The code above would return an Err
result:
1{ 2 ok: false, 3 issues: [ 4 { 5 code: 'string.format.email', 6 input: 'foo', 7 message: 'Must be an email', 8 param: { 9 allowDisplayName: false, 10 allowIPDomain: false, 11 allowUTF8LocalPart: true, 12 blacklistedChars: '', 13 hostBlacklist: [], 14 hostWhitelist: [], 15 ignoreMaxLength: false, 16 requireDisplayName: false, 17 requireTLD: true 18 } 19 } 20 ] 21}
Provide messages
option
to parsing methods:
1const emailShape = d.string().email(); 2 3emailShape.parse('foo', { 4 messages: { 5 'string.format.email': 'Invalid email' 6 } 7}); 8// ❌ ValidationError: string.format.email at /: Invalid email
Or pass a message directly to a plugin method:
1d.string().email('Not an email').parse('foo'); 2// ❌ ValidationError: string.format.email at /: Not an email
More details in the Localization section of Doubter docs.
No vulnerabilities found.
No security vulnerabilities found.