Git Product home page Git Product logo

garden-schema's Introduction

Vanilla Repo Logo

[![](https://img.shields.io/github/license/vanilla/vanilla.svg)](https://github.com/vanilla/vanilla/blob/master/LICENSE) [![CircleCI](https://circleci.com/gh/vanilla/vanilla/tree/master.svg?style=svg)](https://circleci.com/gh/vanilla/vanilla/tree/master)

Howdy, Stranger!

Vanilla was born out of the desire to create flexible, customizable, and downright entertaining community solutions. Vanilla has been used to power tens of thousands of community forums around the world and we couldn't be happier if you've decided to use Vanilla to grow yours.

Forum Rich Editor Dashboard
image image image

Every community is unique. Vanilla is a finely-crafted platform on which designers and developers can build a custom-tailored environment that meets your community's particular needs.

5 reasons Vanilla is the sweetest forum

  1. We've reimagined traditional forums for mass-appeal.
  2. Our theming flexibility is second-to-none.
  3. Impossibly good integration options with single sign-ons and embedding.
  4. The best tools available for community management.
  5. Curated features with great plugin options, not the kitchen sink.

Installation

The current version of Vanilla requires PHP 7.2+ and MySQL 5.7+. The following PHP extensions are also required: cURL, DOM, Fileinfo, GD, intl, JSON, libxml, PDO

Upgrading from an earlier version of Vanilla? See our upgrade notes.

Changes to Fulltext Indexing

Full-text index support has been disabled by default as of Vanilla 4. To enable full-text index support, add a FullTextIndexing key under the Database section of your site config and set its value to true. Failure to add this config value will result in full-text indexes being removed from Vanilla's database tables.

Contributing

Getting Help

Reporting Security Issues

Please disclose security issues responsibly by emailing [email protected] with a full description or join our bug bounty program. We cannot award bounties outside that program.

We'll work on releasing an updated version as quickly as possible. Please do not email non-security issues; use the issue tracker instead.

Building Releases

Vanilla releases are built using Phing to create a pre-built deploy-ready copies of Vanilla. To build these run the following in the root of the repository.

./bin/release

The following dependenies are all required for building a release.

  • node
  • yarn
  • php
  • composer

License & Legal Stuff

Vanilla is free, open source software distributed under the license gpl-2.0-only. We accept and encourage contributions from our community and sometimes give hugs in return.

Copyright © 2009-2022 Vanilla Forums Inc.

Vanilla Forums is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

Vanilla Forums is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Vanilla Forums.

If not, see http://www.gnu.org/licenses/. Contact Vanilla Forums Inc. at support [at] vanillaforums [dot] com

Bonk!

Just kidding, everything's awesome. dance

garden-schema's People

Contributors

acharron-hl avatar charrondev avatar daazku avatar initvector avatar kaecyra avatar linc avatar olivierlamycanuel avatar raffis avatar tburry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

garden-schema's Issues

Add an allowNull stop-gap

This will help with stuff coming from the database and will end up implementing 99% of what array types offer.

Version 2

This is an epic to track features/changes required for version 2 of the library.

Change the validationClass property into a validationFactory property

The validationClass property of Schema allows instances of Validation to be created through cloning. This is not flexible so I propose we allow the Schema to take a factory function or interface for creating validation instances.

If we go the interface route we should use a naming convention similar to PSR-17.

Add scalar values to validation results

The validation object does not contain actual values when giving validation errors which can be a bad UX in some instances. I propose we add values to the validation object if they are simple scalar values.

[API v2] Date time does not validate properly if the timezone is used

@DaazKu commented on Mon Aug 14 2017

Calling http://vanilla.dev/api/v2/comments?discussionid=30 yields:

[
    {
        "commentID": 7,
        "discussionID": 30,
        "body": "<p>comment 1</p>\n",
        "format": "Markdown",
        "dateInserted": "2017-07-27T19:26:24+00:00",
        "insertUserID": 2,
        "url": "http://vanilla.dev/discussion/comment/7#Comment_7"
    },
    {
        "commentID": 8,
        "discussionID": 30,
        "body": "<p>comment 2</p>\n",
        "format": "Markdown",
        "dateInserted": "2017-07-27T19:26:28+00:00",
        "insertUserID": 2,
        "url": "http://vanilla.dev/discussion/comment/8#Comment_8"
    },
    {
        "commentID": 9,
        "discussionID": 30,
        "body": "<p>comment 3</p>\n",
        "format": "Markdown",
        "dateInserted": "2017-07-27T19:26:33+00:00",
        "insertUserID": 2,
        "url": "http://vanilla.dev/discussion/comment/9#Comment_9"
    },
    {
        "commentID": 12,
        "discussionID": 30,
        "body": "<p>asd</p>\n",
        "format": "Markdown",
        "dateInserted": "2017-08-14T14:42:58+00:00",
        "insertUserID": 2,
        "url": "http://vanilla.dev/discussion/comment/12#Comment_12"
    }
]

You get an error using the dateInserted field as the after parameter like so http://vanilla.dev/api/v2/comments?discussionid=30&after=2017-07-27T19:26:24+00:00

{
    "message": "after is not a valid datetime.",
    "status": 422,
    "errors": [
        {
            "field": "after",
            "code": "invalid",
            "message": "after is not a valid datetime."
        }
    ]
}

This is counter intuitive because the return type of dateInserted is DateTime... It should work properly

Add support for CSV fields

Some kind of support should be added for CSV fields. A CSV int field might support "3,4,5" as a valid value and convert it into an array of three integers: 3, 4 and 5.

The details of the feature need to be spec'd out before development.

Add flags for incorrect array keys

Right now, arrays are valid if they contain the zero key. If it is out of order or there are missing/invalid other keys then the schema will clean the output, but that may not be the desired result. Similar to the extra property flags we should add the following flags to the Schema class:

/**
 * Trigger a notice when an array has invalid keys.
 */
const VALIDATE_ARRAY_KEY_NOTICE = 0x4;

/**
 * Throw a ValidationException an array has invalid keys.
 */
const VALIDATE_ARRAY_KEY_EXCEPTION = 0x8;

Create Schema::add() is weird

Currently if we want to create a subset of a schema, given the following schema:

    /**
     * Get a schema instance comprised of all available comment fields.
     *
     * @return Schema Returns a schema object.
     */
    protected function fullSchema() {
        return Schema::parse([
            'commentID:i' => 'The ID of the comment.',
            'discussionID:i' => 'The ID of the discussion.',
            'body:s' => 'The body of the comment.',
            'format:s' => 'The output format of the comment.',
            'dateInserted:dt' => 'When the comment was created.',
            'insertUserID:i' => 'The user that created the comment.',
            'insertUser?' => $this->getUserFragmentSchema(),
            'url:s?' => 'The full URL to the comment.'
        ]);
    }

We have to do:

$this->schema(['commentID', 'discussionID', 'body', 'format'], 'out')->add($this->fullSchema());

This is counter intuitive. Expected result from reading the code would be the fullSchema.
I propose that we create the subSet() function instead.

$this->fullSchema()->subset(['commentID', 'discussionID', 'body', 'format']); 

This is clearer than its counterpart.

Then we should have a fill() utility method that does what add($data, false) does and add() should be refactored to drop $addProperries and have it always add missing properties.

TL;DR;
Create subset() and fill() and make add() only add missing properties.

Schemas do not accept default value

This does not work:

$schema = Schema::parse([
    'letter' => Schema::parse([
        'description' => 'A letter',
        'default' => 'a',
        'items' => [
            'enum' => ['a', 'b', 'c'],
            'type' => 'string'
        ],
        'style' => 'form',
        'type' => 'string',
    ])
]);
$data = [];
$data = $schema->validate($data);
// $data should be ['letter' => 'a']

This does:

$schema = Schema::parse([
    'letter' => [
        'description' => 'A letter',
        'default' => 'a',
        'items' => [
            'enum' => ['a', 'b', 'c'],
            'type' => 'string'
        ],
        'style' => 'form',
        'type' => 'string',
    ]
]);
$data = [];
$data = $schema->validate($data);
// $data should be ['letter' => 'a']

Change field delimiters from "." to "/" to match JSON ref

Currently, we separate fields with "." when adding filters/validators and when representing field nesting in Validation objects. This provides problems when fields have dots in them since we have no escaping. I am recommending we follow the JSON ref spec and use "/" instead.

  • JSON ref uses "/" and escapes it with "1" and escapes "" with "~0".
  • If we want to make this version use deprecations we can just say that a field with dots will throw a deprecation warning and treat it as slashes in addValidator and addFilter`. A mix of dots and slashes should be interpreted as the new style though. Perhaps this allows fields with dots to use a leading slash to start.

Add support for $ref references

A big part of Open API is using $ref references for code reuse. This is something we should support, but is a bit tricky in a narrowly scoped class like Schema. Here is what I propose:

  • Create a schemaContainer property that can take a string from $ref and return a Schema instance.
  • This property will be used to resolve $ref fields when encountered during validation or instantiation.

Filter and validator selectors should support limited wildcards

Right now you can add a validator by specifying the path to a field. Let's add the following wildcards.

  • path.to.field.* will call the callback on any field under path.to.field.
  • .* will call the callback on any property under the root. (might need to be *)
  • * will call the callback on every field, period. (might need to be **)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.