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.

First class field validator

See original GitHub issue

Documenting in person discussion.

It might make sense to have a "type": "field" schema or something along this lines to collect options that apply to the field and not the type of the field, like a "not required" optional that would leave the field unpopulated if it is not included.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
adriangbcommented, Jun 20, 2022

I would also lean towards one single syntax: I imagine these schemas are (mostly) going to be programmatically generated, so having shorthand is only really helpful for writing tests for this package.

1reaction
samuelcolvincommented, Jun 20, 2022

From https://github.com/samuelcolvin/pydantic-core/pull/92#pullrequestreview-1012497346

We want an intermediate dict above schema on a field. This does not affect the rust validators or validation, just the python interface for building schema.

Example:

{
    'type': 'model',
    'fields': {
        'field_a': {
            'required': True,
            'schema': {'type': 'str'},
        },
        'field_b': {
            'default': 123,
            'alias': ...
            'schema': {'type': 'int'},
        },
    }
}

We might add other stuff beyond required, schema, alias.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating your first validator — FluentValidation documentation
To define a set of validation rules for a particular object, you will need to create a class that inherits from AbstractValidator<T> ,...
Read more >
java - How to validate field level constraint before class level ...
Now, if the @Default group gets validated, first the class level constraints and then the field level ones will be validated.
Read more >
RequiredFieldValidator Class (System.Web.UI.WebControls)
Occurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page...
Read more >
Validation - Laravel - The PHP Framework For Web Artisans
To learn about Laravel's powerful validation features, let's look at a complete example of validating a form and displaying the error messages back...
Read more >
Chapter 2. Validation step by step - Red Hat on GitHub
Constraints can be expressed by annotating a field of a class. ... In Section 5.1, “Configuration and ValidatorFactory” we will first show how...
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