예제 #1
0
        /// <summary>
        /// Possibility to check if SagaStep DataJsonSchema is valid before progressing
        /// </summary>
        /// <param name="sagaStep"></param>
        /// <returns></returns>
        public bool DataJsonSchemaIsValid(ISagaStep sagaStep)
        {
            MetaSchemaValidationResults results = CheckDataJsonSchema(sagaStep);

            if (results == null)
            {
                return(false);
            }
            return(results.IsValid);
        }
        private JsonManateeValidator(String schema)
        {
            bool isOk = (!String.IsNullOrEmpty(schema) &&
                         !String.IsNullOrWhiteSpace(schema));

            if (isOk)
            {
                if (this.isSyntacticalValid(schema))
                {
                    JsonValue jsonObj = JsonValue.Parse(schema);
                    bool      isValid = false;
                    if (this.isSemanticalValidSchema(schema))
                    {
                        JsonSchema schemaObj = new JsonSerializer().Deserialize <JsonSchema>(jsonObj);
                        MetaSchemaValidationResults metaResult = schemaObj.ValidateSchema();
                        if (metaResult.IsValid)
                        {
                            this.schema = schemaObj;
                            this.meta   = metaResult;
                            isValid     = true;
                        }
                    }
                    if (!isValid)
                    {
                        throw new ArgumentException("Argument 'schema' must have a " +
                                                    "valid Json Schema format.");
                    }
                }
                else
                {
                    throw new ArgumentException("Argument 'schema' must " +
                                                "be a valid Json string.");
                }
            }
            else
            {
                throw new ArgumentException("Argument 'schema' must be a not null " +
                                            "and a not empty String object, that " +
                                            "have not been only whitspace.");
            }
        }