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.

How to create a schema that has no

See original GitHub issue

Given the following schema:

class CalendarSchema(Schema):
    days_of_month = fields.List(fields.Integer(), default=[], validate=validate.ContainsOnly(range(1, 31 + 1)))

The above schema works fine as long as the array passed contains the value between [1, 31]. However, if the array was an empty array ([]), the validation fails. How can I tweak fields.List such that it accepts an empty array?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
sloriacommented, Mar 19, 2017

After giving this some thought, I think ContainsOnly should accept empty values as valid inputs. Validating against empty vs. non-empty is outside the responsibility of ContainsOnly. If you need to validate that input is non-empty, use Length(min=1).

1reaction
YuriHeupacommented, Nov 16, 2016

Would be nice to have ContainsOnly accepting a param like allow_empty to make empty lists allowed

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL CREATE/ALTER/DROP SCHEMA - w3resource
SQL CREATE/ALTER/DROP SCHEMA: A schema is a logical database object holder. ... If not mentioned the current user is set as the owner....
Read more >
CREATE SCHEMA (Transact-SQL) - Microsoft Learn
CREATE SCHEMA can create a schema, the tables and views it contains, and GRANT, REVOKE, or DENY permissions on any securable in a...
Read more >
CREATE SCHEMA statement - IBM
Identifies a schema called schema-name, whose owner is authorization-name. The schema-name must not identify a schema already described in the catalog (SQLSTATE ...
Read more >
SQL Server CREATE SCHEMA Statement By Examples
In this syntax, First, specify the name of the schema that you want to create in the CREATE SCHEMA clause.
Read more >
CREATE SCHEMA - Snowflake Documentation
Specifies a schema as transient. Transient schemas do not have a Fail-safe period so they do not incur additional storage costs once they...
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