Navigation Menu

Skip to content
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
Merged

Conversation

edoput
Copy link
Contributor

@edoput 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
Copy link

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.

@coveralls
Copy link

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
Copy link

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
Copy link

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.

@nemesifier
Copy link
Member

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.

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
@coveralls
Copy link

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.

@nemesifier nemesifier merged commit a40c0df into openwisp:master May 18, 2017
nemesifier 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants