New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate your input #71

Merged
merged 1 commit into from May 18, 2017

Conversation

Projects
None yet
3 participants
@edoput
Member

edoput commented May 17, 2017

This pr adds a command to validate the netjson input after it has been merged with templates and such.

As an example, using the NetJSON found here

netjsonconfig -c example.json -b openwrt -m validate --verbose
netjsonconfig: JSON Schema violation
ValidationError {u'name': u'radio0', u'country': u'en', u'disabled': False, u'phy': u'phy0', u'tx_power': 18, u'channel': 149, u'channel_width': 20} is not valid under any of the given schemas {u'name': u'radio0', u'country': u'en', u'disabled': False, u'phy': u'phy0', u'tx_power': 18, u'channel': 149, u'channel_width': 20} is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['radios']['items']:
    {'oneOf': [{'$ref': '#/definitions/radio_80211gn_settings'},
               {'$ref': '#/definitions/radio_80211an_settings'},
               {'$ref': '#/definitions/radio_80211ac_2ghz_settings'},
               {'$ref': '#/definitions/radio_80211ac_5ghz_settings'},
               {'$ref': '#/definitions/radio_80211bg_settings'},
               {'$ref': '#/definitions/radio_80211a_settings'}],
     'title': 'Radio'}

On instance['radios'][0]:
    {u'channel': 149,
     u'channel_width': 20,
     u'country': u'en',
     u'disabled': False,
     u'name': u'radio0',
     u'phy': u'phy0',
     u'tx_power': 18}
@coveralls

This comment has been minimized.

coveralls commented May 17, 2017

Coverage Status

Coverage decreased (-0.1%) to 99.862% when pulling d111d3d on EdoPut:validate-your-input into 7d84c64 on openwisp:master.

@edoput edoput force-pushed the edoput:validate-your-input branch from e4f6431 to 4ff7bfb May 17, 2017

@coveralls

This comment has been minimized.

coveralls commented May 17, 2017

Coverage Status

Coverage decreased (-0.1%) to 99.862% when pulling e4f6431 on EdoPut:validate-your-input into 7d84c64 on openwisp:master.

@coveralls

This comment has been minimized.

coveralls commented May 17, 2017

Coverage Status

Coverage decreased (-0.1%) to 99.862% when pulling 4ff7bfb on EdoPut:validate-your-input into 7d84c64 on openwisp:master.

@coveralls

This comment has been minimized.

coveralls commented May 17, 2017

Coverage Status

Coverage decreased (-0.1%) to 99.862% when pulling 4f517f9 on EdoPut:validate-your-input into 7d84c64 on openwisp:master.

@nemesisdesign

This comment has been minimized.

Member

nemesisdesign commented May 17, 2017

Now squash the commits into one, the commit message should be something like:

[module name] Past tense verbe of action performed

Extended descritption

Example:

[bin] Added validate to method options

With this change we can validate NetJSON files via command line.
The patch includes documentation and tests.
[bin] added validate to method options
This method provides a way to check the validity of the NetJSON input
from the command line and can print the ValidationError to the user,
along with a detailed explanation of which part is faulty

@edoput edoput force-pushed the edoput:validate-your-input branch from 4f517f9 to e5b91a1 May 17, 2017

@coveralls

This comment has been minimized.

coveralls commented May 17, 2017

Coverage Status

Coverage decreased (-0.1%) to 99.862% when pulling e5b91a1 on EdoPut:validate-your-input into 7d84c64 on openwisp:master.

@nemesisdesign nemesisdesign merged commit a40c0df into openwisp:master May 18, 2017

1 of 2 checks passed

coverage/coveralls Coverage decreased (-0.1%) to 99.862%
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

nemesisdesign added a commit that referenced this pull request May 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment