RequiredRestriction.js
22 lines
| 1 | import Restriction from './Restriction'; |
| 2 | import { isEmpty } from '../../functions'; |
| 3 | |
| 4 | function RequiredRestriction() { |
| 5 | Restriction.call( this ); |
| 6 | |
| 7 | this.type = 'required'; |
| 8 | } |
| 9 | |
| 10 | RequiredRestriction.prototype = Object.create( Restriction.prototype ); |
| 11 | |
| 12 | RequiredRestriction.prototype.isSupported = function ( node, reporting ) { |
| 13 | return reporting.input.isRequired; |
| 14 | }; |
| 15 | |
| 16 | RequiredRestriction.prototype.validate = function () { |
| 17 | const { current } = this.reporting.input.value; |
| 18 | |
| 19 | return !isEmpty( current ); |
| 20 | }; |
| 21 | |
| 22 | export default RequiredRestriction; |