question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom validator for unknown formats

See original GitHub issue

First of all, great module! It is working really well and saved us a lot of time.

There is an option unknownFormats to ignore custom formats. Is it possible to write your own validator and somehow inject it? Would be nice if I could use the base of this module instead of writing extra code to do same as this module does. Any other suggestions are welcome as well.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cdimasciocommented, Nov 2, 2020

this feature is available in v4.4.0

e.g.

formats: [
  {
    name: 'my-three-digit-format',
    type: 'number',
    // validate returns true the number has 3 digits, false otherwise
    validate: v => /^\d{3}$/.test(v.toString()) 
  },
  {
    name: 'my-three-letter-format',
    type: 'string',
    // validate returns true the string has 3 letters, false otherwise
    validate: v => /^[A-Za-z]{3}$/.test(v)
  },
]
1reaction
rscarsoncommented, Oct 27, 2020

A lot of custom formats could be validated automatically; if the pattern field was set, you could check against the enclosed regex to validate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a replacement for --unknown-formats? #153 - GitHub
Hello, The --unknown-formats option is gone. Is there a replacement? My use case is using a schema for which a format has validation...
Read more >
jsonchema: Custom type, format and validator in Python
Article about adding custom JSON schema types, formats, and validators. Demonstrated on jsonschema validator library for Python.
Read more >
ajv-formats - Ajv JSON schema validator
The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)
Read more >
Validation - Laravel - The PHP Framework For Web Artisans
The custom validator Closure receives three arguments: the name of the $attribute being validated, the $value of the attribute, and an array of...
Read more >
Using VueTypes Validators - GitHub Pages
Custom validators are a special kind of factory function useful to describe complex validation requirements. By design custom validators: don't ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found