Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) 2012, Francis Galiegue <fgaliegue@gmail.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the Lesser GNU General Public License as
  * published by the Free Software Foundation, either version 3 of the
  * License, or (at your option) any later version.
  *
  * This program 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
 * Lesser GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.github.fge.jsonschema.syntax.draftv3;
Syntax validator for the properties keyword

In fact, what this validator really does is check that a required member in a value, if any, is a boolean.

public final class DraftV3PropertiesSyntaxChecker
    extends AbstractSyntaxChecker
    private static final SyntaxChecker INSTANCE
        = new DraftV3PropertiesSyntaxChecker();
    {
        super("properties".);
    }
    public static SyntaxChecker getInstance()
    {
        return ;
    }
    @Override
    public void checkValue(final SyntaxValidator validator,
        final List<Messagemessagesfinal JsonNode schema)
    {
        final JsonNode node = schema.get();
        final Set<Stringfields = Sets.newHashSet(node.fieldNames());
        NodeType type;
        JsonNode element;
        Message.Builder msg;
        for (final String field: Ordering.natural().sortedCopy(fields)) {
            msg = newMsg().addInfo("key"field);
            element = node.get(field);
            /*
             * Check that member values are JSON objects (schemas)
             */
            type = NodeType.getNodeType(element);
            if (type != .) {
                msg.setMessage("key value has incorrect type")
                    .addInfo("expected".)
                    .addInfo("found"type);
                messages.add(msg.build());
                continue;
            }
            /*
             * If the subschema has a "required" member name, check that the
             * value is a boolean
             */
            if (element.has("required")) {
                type = NodeType.getNodeType(element.get("required"));
                if (type != .) {
                    msg.setMessage("\"required\" attribute has incorrect type")
                        .addInfo("expected".)
                        .addInfo("found"type);
                    messages.add(msg.build());
                    continue;
                }
            }
            validator.validate(messageselement);
        }
    }
New to GrepCode? Check out our FAQ X